method

sqlite.Statement.safeIntegers

enabled: boolean
): this;

Set whether this statement returns integers as bigint. The default is the safeIntegers option of the Database.

With false, integers are returned as number, and integers beyond 53 bits are rounded to the nearest number. The setting also decides the type of lastInsertRowid in the result of run.

Database.query returns the same Statement for the same SQL, so the setting stays for its next caller.

@returns

The same statement

db.run("CREATE TABLE foo (id INTEGER PRIMARY KEY, big INTEGER)");
db.run("INSERT INTO foo (big) VALUES (?)", BigInt(Number.MAX_SAFE_INTEGER) + 10n);
const stmt = db.prepare("SELECT * FROM foo");

stmt.all();
// => [{ id: 1, big: 9007199254741000 }]

stmt.safeIntegers(true).all();
// => [{ id: 1n, big: 9007199254741001n }]
safeIntegers(): boolean;

Whether this statement returns integers as bigint.