Class StubDatabaseAdapter<T>

A database adapter is an interface by which entity objects can be fetched, inserted, updated, and deleted from a database. This base class handles all entity field transformation. Subclasses are responsible for implementing database-specific logic for a type of database.

Type Parameters

  • T extends Record<string, any>

Hierarchy (view full)

Constructors

Methods

  • Fetch many objects where fieldName is one of fieldValues.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • queryContext: EntityQueryContext

      query context with which to perform the fetch

    • fieldName: K

      object field being queried

    • fieldValues: readonly NonNullable<T[K]>[]

      fieldName field values being queried

    Returns Promise<ReadonlyMap<NonNullable<T[K]>, readonly Readonly<T>[]>>

    map from fieldValue to objects that match the query for that fieldValue

  • Update an object.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • queryContext: EntityQueryContext

      query context with which to perform the update

    • idField: K

      the field in the object that is the ID

    • id: any

      the value of the ID field in the object

    • object: Readonly<Partial<T>>

      the object to update

    Returns Promise<Readonly<T>>

    the updated object