Bun

interface

sqlite.DatabaseOptions

interface DatabaseOptions

Options for Database

  • create?: boolean

    Allow creating a new database

    Equivalent to constants.SQLITE_OPEN_CREATE

  • readonly?: boolean

    Open the database as read-only (no write operations, no create).

    Equivalent to constants.SQLITE_OPEN_READONLY

  • readwrite?: boolean

    Open the database as read-write

    Equivalent to constants.SQLITE_OPEN_READWRITE

  • safeIntegers?: boolean

    When set to true, integers are returned as bigint types.

    When set to false, integers are returned as number types and truncated to 52 bits.

  • strict?: boolean

    When set to false or undefined:

    • Queries missing bound parameters will NOT throw an error
    • Bound named parameters in JavaScript need to exactly match the SQL query.
    const db = new Database(":memory:", { strict: false });
    db.run("INSERT INTO foo (name) VALUES ($name)", { $name: "foo" });
    

    When set to true:

    • Queries missing bound parameters will throw an error
    • Bound named parameters in JavaScript no longer need to be $, :, or @. The SQL query will remain prefixed.