interface
SQL.ResultMetadata
interface ResultMetadata
Properties of the array that a query resolves to, next to the rows. They are accessors on the prototype, not own properties, so console.log, Object.keys, JSON.stringify and spreading only see the rows.
A query with several statements (.simple(), a MySQL CALL) resolves to a plain array of results. The metadata is on each inner array.
- affectedRows: number
The number of rows that an
INSERT,UPDATE,DELETEorMERGEwrote.0for a statement that writes nothing.PostgreSQL tags
CREATE TABLE AS, and aSELECTwhose CTE writes, asSELECT, so it is0for them. MariaDB reportsINSERT ... RETURNINGas a result set, so it is0there too. - columns: null | ResultColumn[]
The columns of the result, also when it has no rows and with
.values()or.raw(). Empty for a statement that returns no rows, such as a plainINSERT.nullon SQLite. - command: null | string
The kind of statement. PostgreSQL: the command tag, such as
"INSERT"or"CREATE TABLE". SQLite: the first keyword. MySQL:null, because the protocol does not report it. - count: number
The number of rows returned, or the number of rows written when the statement returns none
- lastInsertRowid: null | string | number | bigint
The key that an
INSERTgenerated.- PostgreSQL:
null. UseRETURNING. - MySQL: the first
AUTO_INCREMENTvalue of the statement,0if there is none. AboveNumber.MAX_SAFE_INTEGERit is a string, or aBigIntwithbigint: true. - SQLite: the
rowidof the last inserted row, also after a statement that inserts nothing.nullfor a statement that only reads. ABigIntwithsafeIntegers: trueorbigint: true.
- PostgreSQL:
- statement: null | ResultStatement
The text, the parameter types and the columns of the statement.
nullon SQLite.