method

sqlite.Database.fileControl

op: number,
arg?: null | number | ArrayBufferView<ArrayBufferLike>
): number;

Call sqlite3_file_control on the main database.

SQLite reads the input of op from arg and writes its output there.

  • A number is passed as a 32-bit integer. What SQLite writes back is not returned.
  • A TypedArray or DataView of at least 8 bytes is passed as is. Use it to read what SQLite writes back.
  • null or no argument is for an op that takes none, such as SQLITE_FCNTL_RESET_CACHE. An op that reads its argument reads -1.
@returns

The SQLite status code. 0 is SQLITE_OK. 12 is SQLITE_NOTFOUND: the VFS does not implement op, or the database is in memory.

// -1 asks for the flag. SQLite writes 0 or 1 to the first element.
const flag = new Int32Array([-1, 0]);
db.fileControl(constants.SQLITE_FCNTL_PERSIST_WAL, flag);
console.log(flag[0]);
zDbName: string,
op: number,
arg?: null | number | ArrayBufferView<ArrayBufferLike>
): number;

Call sqlite3_file_control on the database with the schema name zDbName: "main" or the name of an attached database.