property
sqlite.Statement.declaredTypes
readonly declaredTypes: null | string[]
The declared column types from the table schema, as reported by sqlite3_column_decltype().
Returns an array of:
- The exact type string declared in the
CREATE TABLEstatement nullfor columns without declared types, such as expressions and computed columns
The statement must be executed at least once before accessing this property. Available for both read-only and read-write statements.
// For table columns:
const stmt = db.prepare("SELECT id, name, weight FROM products");
stmt.get();
console.log(stmt.declaredTypes);
// => ["INTEGER", "TEXT", "REAL"]
// For expressions (no declared types):
const exprStmt = db.prepare("SELECT length('bun') AS str_length");
exprStmt.get();
console.log(exprStmt.declaredTypes);
// => [null]