@photostructure/sqlite
    Preparing search index...

    Interface SqliteModule

    The main SQLite module interface.

    interface SqliteModule {
        backup: (
            sourceDb: DatabaseSyncInstance,
            destination: string | Buffer<ArrayBufferLike> | URL,
            options?: BackupOptions,
        ) => Promise<number>;
        constants: SqliteConstants;
        Database: new (
            location?: string | Buffer<ArrayBufferLike> | URL,
            options?: DatabaseSyncOptions,
        ) => DatabaseSyncInstance;
        DatabaseSync: new (
            location?: string | Buffer<ArrayBufferLike> | URL,
            options?: DatabaseSyncOptions,
        ) => DatabaseSyncInstance;
        Session: new () => Session;
        Statement: new (
            database: DatabaseSyncInstance,
            sql: string,
            options?: StatementOptions,
        ) => StatementSyncInstance;
        StatementSync: new (
            database: DatabaseSyncInstance,
            sql: string,
            options?: StatementOptions,
        ) => StatementSyncInstance;
    }
    Index
    backup: (
        sourceDb: DatabaseSyncInstance,
        destination: string | Buffer<ArrayBufferLike> | URL,
        options?: BackupOptions,
    ) => Promise<number>

    Type Declaration

      • (
            sourceDb: DatabaseSyncInstance,
            destination: string | Buffer<ArrayBufferLike> | URL,
            options?: BackupOptions,
        ): Promise<number>
      • Standalone function to make a backup of a database.

        This function matches the Node.js node:sqlite module API which exports backup() as a standalone function in addition to the db.backup() method.

        Parameters

        • sourceDb: DatabaseSyncInstance

          The database to backup from.

        • destination: string | Buffer<ArrayBufferLike> | URL

          The path where the backup will be created.

        • Optionaloptions: BackupOptions

          Optional configuration for the backup operation.

        Returns Promise<number>

        A promise that resolves when the backup is completed.

        import { DatabaseSync, backup } from '@photostructure/sqlite';

        const db = new DatabaseSync('./source.db');
        await backup(db, './backup.db');

        // With options
        await backup(db, './backup.db', {
        rate: 10,
        progress: ({ totalPages, remainingPages }) => {
        console.log(`Progress: ${totalPages - remainingPages}/${totalPages}`);
        }
        });

    backup

    constants: SqliteConstants

    SQLite constants for various operations and flags.

    Database: new (
        location?: string | Buffer<ArrayBufferLike> | URL,
        options?: DatabaseSyncOptions,
    ) => DatabaseSyncInstance

    The Database class represents a synchronous connection to a SQLite database. All operations are performed synchronously, blocking until completion.

    DatabaseSync: new (
        location?: string | Buffer<ArrayBufferLike> | URL,
        options?: DatabaseSyncOptions,
    ) => DatabaseSyncInstance

    The pre-rename name of SqliteModule.Database, kept as an alias. Node.js deprecates it in documentation only (DEP0210).

    Session: new () => Session

    The Session class for recording database changes. This class should not be instantiated directly; use Database.createSession() instead.

    Statement: new (
        database: DatabaseSyncInstance,
        sql: string,
        options?: StatementOptions,
    ) => StatementSyncInstance

    The Statement class represents a synchronous prepared statement. This class should not be instantiated directly; use Database.prepare() instead.

    StatementSync: new (
        database: DatabaseSyncInstance,
        sql: string,
        options?: StatementOptions,
    ) => StatementSyncInstance

    The pre-rename name of SqliteModule.Statement, kept as an alias. Node.js deprecates it in documentation only (DEP0211).