SurrealDB Docs Logo

Enter a search query

.Select[T, R](resource)

Selects all records in a table, or a specific record, from the database.

Method Syntax
db.Select[T, R](resource)

Arguments

ArgumentsDescription
resource required

The table name (as models.Table) for selecting all records or a RecordID (as models.RecordID) to select a single record.

T required

The type to deserialize the result into, such as Person for a single record or []Person for an array of records.

R required

The type of the resource parameter—use models.RecordID for a single record or models.Table for an entire table.

Example usage

// Get entry by Record ID person, err := surrealdb.Select[Person, models.RecordID](db, *person1.ID) if err != nil { panic(err) } fmt.Printf("Selected a person by record id: %+v\n", person) // Or retrieve the entire table persons, err := surrealdb.Select[[]Person, models.Table](db, models.Table("persons")) if err != nil { panic(err) } fmt.Printf("Selected all in persons table: %+v\n", persons)

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install