Documentation
    Preparing search index...

    Backend adapter implementation for SQLite databases. Uses the sqlite driver to provide a fast, local relational store without external dependencies. Highly useful for local development, CI/CD testing environments, or lightweight local deployments.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _alias: string = ''
    _connection: Database<Database, Statement> | undefined
    _dbPath: 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

    • Convert array into SQL expression

      Parameters

      • from: (string | number)[]

        Array of strings or numbers

      Returns string

      string

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

      Parameters

      Returns string

    • Returns Promise<Database<Database, Statement>>

    • Process data for compatibility

      Parameters

      • data: any
      • filterNulls: boolean = true

      Returns any[]

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

    • Close the SQLite connection

      Returns Promise<void>

    • Translates a DataObject creation request into an INSERT INTO SQL query. SQLite handles JSON by parsing array properties internally.

      Parameters

      • dataObject: DataObjectClass<any>

        The DataObject payload.

      • desiredUid: string | undefined

        Optional explicit UUID.

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the saved DataObject.

    • Generates a DELETE FROM or UPDATE query depending on the hardDelete parameter.

      Parameters

      • dataObject: DataObjectClass<any>

        The DataObject to remove.

      • hardDelete: boolean = false

        Force permanent deletion over soft delete.

      Returns Promise<DataObjectClass<any>>

      A promise resolving upon completion.

    • Wipes all records from a table by executing a blanket DELETE FROM.

      Parameters

      • collection: string

        The table name to purge.

      • batchSize: number = 500

        Ignored for SQLite bulk 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.

    • 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

      • collection: string
      • delta: any

      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 an arbitrary raw SQL query against the SQLite database.

      Parameters

      • sql: string

        The SQL statement with optional ? parameterized placeholders.

      • params: any[] = []

        The array of parameter values.

      Returns Promise<any>

      A promise resolving to the SQLite result rows.

    • Executes a SELECT * query to retrieve a document by its UID. Handles mapping of JSON text columns back into arrays/objects.

      Parameters

      • dataObject: DataObjectClass<any>

        The empty DataObject containing the target path.

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the hydrated 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

    • Processes an UPDATE command for modified object properties. Automatically ensures the table exists and properly escapes JSON-backed properties.

      Parameters

      Returns Promise<DataObjectClass<any>>

      A promise resolving to the updated instance.