SQLite for Nativescript
    Preparing search index...

    Class Database

    The query methods, shared by a database and by a transaction.

    Hierarchy

    • QueryApi
      • Database

    Implements

    Index

    Constructors

    • Parameters

      • backend: Backend
      • resolvedPath: string
      • Optionaloptions: DatabaseOptions
      • Optionalengines: string[]

      Returns Database

    Properties

    backend: Backend
    filePath: string
    ready: Promise<void>

    resolves when the database is opened, rejects with the open error

    Accessors

    • get isOpen(): boolean

      true once the database is opened and until it is closed

      Returns boolean

    Methods

    • false when the engine in use cannot load extensions (loadExtension would reject)

      Returns boolean

    • Returns Promise<void>

    • streams rows in chunks, resolves with the number of rows

      Parameters

      Returns Promise<number>

    • run several statements separated by ;, without parameters

      Parameters

      • script: string

      Returns Promise<void>

    • Blocking variants: they wait for the database thread on the calling thread, saving the event loop round trip for small statements in a loop, and block it for the whole statement. Node-API binding only (NativeScript >= 9.1).

      Parameters

      Returns ExecResult

    • version of the SQLite library in use

      Returns string

    • Returns Promise<any>

    • Returns any

    • Loads a SQLite extension into this connection; needs an engine that allows it (see canLoadExtensions). entryPoint defaults to the one SQLite derives from the file name (libfoo.so -> sqlite3_foo_init).

      Parameters

      • path: string
      • OptionalentryPoint: string

      Returns Promise<void>

    • Parameters

      • version: number

      Returns Promise<void>

    • Runs action in a transaction: COMMIT when it resolves, ROLLBACK when it throws or cancel() was called. Other calls made on this database meanwhile join it (use tx to be explicit); requests of other parts of the app wait for the end.

      Type Parameters

      • T = any

      Parameters

      Returns Promise<T>

    • the transaction a call belongs to, 0 for none

      Returns number