• Start

Languages

/

Swift

/

Methods

create

The create() method for the SurrealDB Swift SDK creates a record in the database.

Creates a record in the database, either with an auto-generated id or a specific id.

Method Syntax

try await client.create(content)
ArgumentsDescription
content The model instance to create. The table is derived from the model.
recordID A SurrealRecordID to create the record with a specific id.
// 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)
)

Was this page helpful?