prorm API Reference
    Preparing search index...

    Class SurrealStore

    SurrealStore wraps the surrealdb driver's Surreal client, exposing record CRUD (create/select/update/merge/delete) and raw SurrealQL (query) as a small promise-based API.

    Implements

    Index
    name: "surrealdb" = 'surrealdb'

    The name of the store (e.g. 'mongodb', 'redis', 'dynamodb')

    library: "surrealdb" = 'surrealdb'

    The client library being used

    • Create a record. thing may be a table name ('user', id auto- generated) or a specific record id ('user:jane'). Passthrough to the driver's Surreal.create().

      Type Parameters

      • T = unknown

      Parameters

      • thing: string
      • Optionaldata: Record<string, unknown>

      Returns Promise<T>

    • Select a record or all records in a table. Passthrough to the driver's Surreal.select().

      Type Parameters

      • T = unknown

      Parameters

      • thing: string

      Returns Promise<T>

    • Replace the content of a record (or every record in a table). Passthrough to the driver's Surreal.update().

      Type Parameters

      • T = unknown

      Parameters

      • thing: string
      • Optionaldata: Record<string, unknown>

      Returns Promise<T>

    • Merge the given data into a record (or every record in a table), leaving unspecified fields intact. Passthrough to the driver's Surreal.merge().

      Type Parameters

      • T = unknown

      Parameters

      • thing: string
      • Optionaldata: Record<string, unknown>

      Returns Promise<T>

    • Delete a record (or every record in a table). Passthrough to the driver's Surreal.delete().

      Type Parameters

      • T = unknown

      Parameters

      • thing: string

      Returns Promise<T>

    • Run a raw SurrealQL statement (or several ;-separated statements), optionally binding vars as $name parameters. Returns the driver's result array (one entry per statement). Passthrough to the driver's Surreal.query().

      Type Parameters

      • T = unknown[]

      Parameters

      • surql: string
      • Optionalvars: Record<string, unknown>

      Returns Promise<T>

    • ORM findAll. Compiles where/order/limit/offset to a bound SurrealQL SELECT; on an un-pushable operator it selects the table and filters/sorts/paginates client-side, so the result is always correct.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • table: string
      • options: SurrealFindOptions = {}

      Returns Promise<T[]>

    • ORM findOne: the first row matching where (respecting order).

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • table: string
      • options: SurrealFindOptions = {}

      Returns Promise<T | null>

    • ORM findByPk: select a single table:id record, or null.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • table: string
      • id: unknown

      Returns Promise<T | null>

    • ORM count: number of records matching where.

      Parameters

      • table: string
      • Optionalwhere: WhereClause

      Returns Promise<number>

    • ORM bulkCreate: insert many records in one INSERT statement.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • table: string
      • rows: Record<string, unknown>[]

      Returns Promise<T[]>

    • ORM update: merge values into every record matching where (or the whole table when where is omitted). Returns the updated records.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • table: string
      • values: Record<string, unknown>
      • Optionalwhere: WhereClause

      Returns Promise<T[]>

    • ORM destroy: delete every record matching where (or the whole table when where is omitted). Returns the number of records deleted.

      Parameters

      • table: string
      • Optionalwhere: WhereClause

      Returns Promise<number>

    • ORM truncate: delete every record in a table.

      Parameters

      • table: string

      Returns Promise<number>

    • Create a graph edge (association) between two records: RELATE $from->edge->$to CONTENT $data. This is how many-to-many / graph associations are expressed in SurrealDB, exposed through the ORM API so callers never hand-write the RELATE themselves.

      Type Parameters

      • T = unknown

      Parameters

      • from: string
      • edge: string
      • to: string
      • Optionaldata: Record<string, unknown>

      Returns Promise<T>