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)Arguments
Arguments | Description |
|---|---|
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 |
Example usage
// 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)