Creates a record in the database, either with an auto-generated id or a specific id.
Method Syntax
try await client.create(content)Arguments
Arguments | Description |
|---|---|
content | The model instance to create. The table is derived from the model. |
recordID | A |
Example usage
// Create with an auto-generated id
let created: [Person] = try await client.create(Person(id: nil, name: "Ada", age: 30))
// Create with a specific id
let id = SurrealRecordID(table: "person", id: .string("ada"))
let record: Person? = try await client.create(
recordID: id,
content: Person(id: nil, name: "Ada", age: 30)
)