Documentation
    Preparing search index...

    Backend adapter implementation for Google Cloud Firestore. Maps Quatrain's DataObjects and Queries to Firestore documents and collections. Inherits all baseline CRUD and Query logic from AbstractBackendAdapter.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _alias: string = ''
    _middlewares: BM[] = []
    _params: BackendParameters = {}
    PKEY_IDENTIFIER: FieldPath = ...

    The reserved field path identifier for a document's primary key in Firestore.

    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

    • Parameters

      • db: Firestore
      • query: Query
      • resolve: any

      Returns Promise<void>

    • 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.

    • Removes a document from Firestore. If softDelete is enabled in backend parameters and hardDelete is false, it updates the document's status to DELETED instead of destroying the record.

      Parameters

      • dataObject: DataObjectClass<any>

        The DataObject representing the document to delete.

      • hardDelete: boolean = false

        Force absolute removal even if softDelete is globally enabled.

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the processed DataObject (with cleared URI if hard deleted).

    • Completely obliterates an entire collection by batch-deleting all its documents recursively. Use with extreme caution.

      Parameters

      • collection: string

        The name of the root collection to delete.

      • batchSize: number = 500

        The number of documents to delete per transaction chunk.

      Returns Promise<void>

      A promise resolving when the collection is empty.

    • 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.

    • Generates raw SQL for creating a table.

      Parameters

      • collection: string
      • properties: any[]

      Returns { downSql: string; upSql: string }

      Always throws because Firestore is a NoSQL database and does not support SQL generation.

    • Generates raw SQL for altering a table schema.

      Parameters

      • collection: string
      • delta: any

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

      Always throws because Firestore does not support relational schema deltas.

    • 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>

    • Retrieves a document from Firestore by its path and populates the given DataObject.

      Parameters

      • dataObject: DataObjectClass<any>

        The target DataObject containing the path/UID to fetch.

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the populated DataObject.

      If no document exists at the calculated path.

      If the path is improperly formatted.

    • 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

    • Updates an existing document in Firestore with the current state of the DataObject. Executes attached middlewares before and after the transaction.

      Parameters

      • dataObject: DataObjectClass<any>

        The DataObject containing the updated payload.

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the updated DataObject.

      If the parent references are invalid or the object has no UID.