prorm API Reference
    Preparing search index...

    Class RethinkDBStore

    RethinkDBStore wraps the rethinkdb-ts term-builder (r) in a small, promise-based convenience layer over document CRUD, ReQL filter queries, and table/database creation, plus a run() escape hatch for arbitrary ReQL terms.

    Implements

    Index
    name: "rethinkdb" = 'rethinkdb'

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

    library: "rethinkdb-ts" = 'rethinkdb-ts'

    The client library being used

    • Insert a document (or array of documents) into table.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • doc: Record<string, unknown> | Record<string, unknown>[]

      Returns Promise<T>

    • Fetch a single document from table by its primary key. Resolves to null if not found.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • id: unknown

      Returns Promise<T | null>

    • Partially update the document with primary key id in table, merging patch.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • id: unknown
      • patch: Record<string, unknown>

      Returns Promise<T>

    • Delete the document with primary key id from table.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • id: unknown

      Returns Promise<T>

    • Return all documents in table matching predicate as an array. predicate is any ReQL filter argument - a match object ({ active: true }) or a predicate function (row => row('age').gt(18)). The result is materialized (cursor drained to an array) before returning.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • predicate: unknown

      Returns Promise<T[]>

    • Fetch all documents in table matching an ORM where clause, with optional ordering, offset, and limit. The where object accepts the full ORM operator surface (Op.gt, Op.in, Op.like, Op.and/Op.or, ...), translated to a native ReQL filter predicate - so standard queries never require hand-written ReQL.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • where: Record<string | symbol, unknown> = {}
      • options: RethinkFindOptions = {}

      Returns Promise<T[]>

    • Fetch the first document in table matching an ORM where clause (respecting order), or null.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • where: Record<string | symbol, unknown> = {}
      • options: Omit<RethinkFindOptions, "limit"> = {}

      Returns Promise<T | null>

    • Count documents in table matching an ORM where clause.

      Parameters

      • table: string
      • where: Record<string | symbol, unknown> = {}

      Returns Promise<number>

    • Update every document in table matching an ORM where clause, merging patch.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • where: Record<string | symbol, unknown>
      • patch: Record<string, unknown>

      Returns Promise<T>

    • Delete every document in table matching an ORM where clause.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • where: Record<string | symbol, unknown>

      Returns Promise<T>

    • Insert doc, updating (or replacing) the existing row on a primary-key conflict - RethinkDB's native upsert via insert(..., { conflict }).

      Type Parameters

      • T = any

      Parameters

      • table: string
      • doc: Record<string, unknown> | Record<string, unknown>[]
      • conflict: "replace" | "update" = 'update'

      Returns Promise<T>

    • Distinct values of field across table (optionally over a secondary index).

      Type Parameters

      • T = any

      Parameters

      • table: string
      • Optionalfield: string
      • Optionalindex: string

      Returns Promise<T[]>

    • Fetch documents whose key (or secondary-index value) is one of keys.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • keys: unknown[]
      • Optionalindex: string

      Returns Promise<T[]>

    • Grouped aggregation over table using ReQL's native group/reduction chain (count/sum/avg/min/max), with an optional ORM where pre-filter. Returns one entry per group: { group, ...aggregates }.

      Parameters

      • table: string
      • options: RethinkAggregateOptions = {}

      Returns Promise<Record<string, unknown>[]>

    • Create a secondary index on table. indexer may be a field name, list of fields (compound), or a ReQL function.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • name: string
      • Optionalindexer: unknown
      • Optionaloptions: Record<string, unknown>

      Returns Promise<T>

    • Drop a secondary index from table.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • name: string

      Returns Promise<T>

    • List secondary index names on table.

      Parameters

      • table: string

      Returns Promise<string[]>

    • Wait for one or all secondary indexes on table to finish building.

      Type Parameters

      • T = any

      Parameters

      • table: string
      • ...names: string[]

      Returns Promise<T>

    • Create a table. Pass a single name to create it in the connection's default database, or (db, name) to create it in a specific database.

      Type Parameters

      • T = any

      Parameters

      • dbOrName: string
      • Optionalname: string

      Returns Promise<T>

    • Drop a table. Pass a single name, or (db, name) for a specific database.

      Type Parameters

      • T = any

      Parameters

      • dbOrName: string
      • Optionalname: string

      Returns Promise<T>

    • List tables in the default (or given) database.

      Parameters

      • Optionaldb: string

      Returns Promise<string[]>

    • Create a database.

      Type Parameters

      • T = any

      Parameters

      • name: string

      Returns Promise<T>

    • Drop a database.

      Type Parameters

      • T = any

      Parameters

      • name: string

      Returns Promise<T>

    • RethinkDB has no multi-document transactions. Single-document writes are atomic, and updateWhere/deleteWhere apply atomically per document, but there is no way to commit changes across documents/tables as a unit. This throws a clear, typed capability error rather than silently pretending to provide isolation.

      Type Parameters

      • T

      Parameters

      • _fn: (store: this) => Promise<T>

      Returns Promise<never>

    • Run an arbitrary ReQL query term (built from getClient()), for operations not wrapped here. In single-connection mode the store's connection is supplied to .run() automatically.

      Type Parameters

      • T = any

      Parameters

      • query: any

      Returns Promise<T>