Documentation
    Preparing search index...

    Class AbstractBackendAdapterAbstract

    The baseline abstract class defining the contract for all Quatrain database adapters. Implementations must extend this class to translate agnostic CRUD operations into specific database queries (e.g., PostgreSQL, Firestore). It also handles middleware execution lifecycles.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    _alias: string = ''
    _middlewares: BM[] = []
    _params: BackendParameters = {}
    PKEY_IDENTIFIER: any = 'id'

    The string identifier for primary keys, mapped to 'id' by default.

    Accessors

    • get alias(): string

      Returns string

    • set alias(alias: string): void

      Parameters

      • alias: string

      Returns void

    Methods

    • Resolves the canonical database path for a record, respecting standard collection structures and hierarchical subcollection configurations.

      Parameters

      Returns string

    • Processes raw data entries to convert relational reference objects into native database foreign key IDs if the adapter has been configured with useNativeForeignKeys = true.

      Parameters

      • data: any[]

      Returns any[]

    • Attaches a new middleware to the adapter's execution pipeline. Middlewares are triggered before or after database actions.

      Parameters

      • middleware: BM

        The instantiated middleware to attach.

      Returns void

      If a middleware with the same class name is already attached.

    • Executes an aggregation operation (sum, avg, distinct, min, max, count) on a query. The default implementation fetches all matching records and performs in-memory aggregation. Specific database adapters should override this to perform native query aggregation.

      Parameters

      • query: Query<any>

        The Query instance defining the collection and filters.

      • operation: "sum" | "avg" | "distinct" | "min" | "max" | "count"

        The aggregate operation.

      • Optionalproperty: string

        The name of the property to aggregate.

      Returns Promise<any>

      A promise resolving to the aggregated result.

    • Adapter-specific implementation for inserting new records.

      Parameters

      • dataObject: DataObjectClass<any>

        The payload.

      • OptionaldesiredUid: string

        Optional explicit UID to use.

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the created object.

    • Adapter-specific implementation for removing an entire collection.

      Parameters

      • collection: string

        The collection name.

      • OptionalbatchSize: number

        The pagination batch limit for NoSQL sequential deletes.

      Returns Promise<void>

    • Removes a middleware from the pipeline by its class name.

      Parameters

      • middlewareClassName: string

        The exact name of the middleware class to remove.

      Returns void

    • Orchestrates the sequential execution of all attached middlewares for a given action.

      Parameters

      • dataObject: DataObjectClass<any>

        The payload traversing the middlewares.

      • action: BackendAction

        The context (READ, CREATE, UPDATE, DELETE).

      • timing: "before" | "after" = 'before'

        Whether to run the before or after pipeline.

      • Optionalparams: MiddlewareParams

        Optional parameters passed down to the middlewares.

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the potentially mutated DataObject.

    • Adapter-specific implementation translating complex Query constructs into raw database statements.

      Parameters

      • dataObject: DataObjectClass<any>

        Base template object representing the queried collection.

      • filters: Filter[] | Filters | undefined

        The compiled list of WHERE filters.

      • pagination: SortAndLimit | undefined

        Limits, offsets, and sorting directions.

      • parent: any

        Optional linked parent object for nested lookups.

      Returns Promise<QueryResultType<any>>

      A promise resolving to an array of objects and result metadata.

    • Generates the SQL up and down statements to create a collection table.

      Parameters

      • collection: string
      • properties: any[]

      Returns { downSql: string; upSql: string }

    • Generates the SQL up and down statements to apply a schema delta to a collection.

      Parameters

      Returns { downSql: string[]; upSql: string[] }

    • Helper method to extract the destination collection name from a DataObject.

      Parameters

      Returns string | undefined

      The resolved collection string.

    • Retrieves a specific configuration parameter.

      Parameters

      • key: BackendParametersKeys

        The parameter key to fetch.

      Returns any

      The value associated with the key, or undefined.

    • Returns true if a given middleware is attached

      Parameters

      • className: string

      Returns boolean

      boolean

    • Outputs an adapter-level diagnostic message to the console if debug mode is enabled.

      Parameters

      • message: string

        The textual content to log.

      Returns void

      Use Backend.debug() or Backend.log() (which itself is deprecated in favor of specific levels) instead.

    • Executes a raw query on the backend. Only supported by SQL adapters.

      Parameters

      • sql: string
      • Optionalparams: any[]

      Returns Promise<any>

    • Adapter-specific implementation for reading a record by its UID/path.

      Parameters

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the populated DataObject.

    • Overrides or adds a backend configuration parameter dynamically.

      Parameters

      • key: BackendParametersKeys

        The parameter key to modify.

      • value: any

        The new value to assign.

      Returns void