• Start

Languages

/

Swift

/

Methods

select

The select() method for the SurrealDB Swift SDK selects all records in a table, or a specific record.

Selects all records of a model's table, a filtered subset, or a single record by id.

Method Syntax

try await client.select(Model.self, where: predicate, limit: limit,
start: start)
ArgumentsDescription
model The model type to select, e.g. Person.self.
where A predicate restricting which records are returned.
limit / start Paginate the results by limiting the count and offsetting the start.
recordID Select a single record by its SurrealRecordID instead of a table.
// Select all records
let people = try await client.select(Person.self)

// Select a filtered, paginated subset
let adults = try await client.select(
Person.self,
where: Person.Fields.age >= 18,
limit: 20,
start: 0
)

// Select a single record by id
let id = SurrealRecordID(table: "person", id: .string("ada"))
let person: Person? = try await client.select(recordID: id,
as: Person.self)

Was this page helpful?