@@ -1295,27 +1295,33 @@ are no subscribers.
12951295
12961296### Channel ` sqlite.db.query `
12971297
1298- The message published to this channel is a {string} containing the expanded
1299- SQL with bound parameter values substituted. If expansion fails, the source
1300- SQL with unsubstituted placeholders is used instead.
1298+ The message published to this channel is an {Object} with the following
1299+ properties:
1300+
1301+ * ` sql ` {string} The expanded SQL with bound parameter values substituted.
1302+ If expansion fails, the source SQL with unsubstituted placeholders is used
1303+ instead.
1304+ * ` database ` {DatabaseSync} The ` DatabaseSync ` instance that executed the
1305+ statement.
1306+ * ` duration ` {number} The estimated statement run time in nanoseconds.
13011307
13021308``` cjs
13031309const dc = require (' node:diagnostics_channel' );
13041310const { DatabaseSync } = require (' node:sqlite' );
13051311
1306- function onQuery (sql ) {
1307- console .log (sql);
1312+ function onQuery ({ sql, database, duration } ) {
1313+ console .log (sql, duration );
13081314}
13091315
13101316dc .subscribe (' sqlite.db.query' , onQuery);
13111317
13121318const db = new DatabaseSync (' :memory:' );
13131319db .exec (' CREATE TABLE t (x INTEGER)' );
1314- // Logs: CREATE TABLE t (x INTEGER)
1320+ // Logs: CREATE TABLE t (x INTEGER) <duration>
13151321
13161322const stmt = db .prepare (' INSERT INTO t VALUES (?)' );
13171323stmt .run (42 );
1318- // Logs: INSERT INTO t VALUES (42.0)
1324+ // Logs: INSERT INTO t VALUES (42.0) <duration>
13191325
13201326dc .unsubscribe (' sqlite.db.query' , onQuery);
13211327```
@@ -1324,19 +1330,19 @@ dc.unsubscribe('sqlite.db.query', onQuery);
13241330import dc from ' node:diagnostics_channel' ;
13251331import { DatabaseSync } from ' node:sqlite' ;
13261332
1327- function onQuery (sql ) {
1328- console .log (sql);
1333+ function onQuery ({ sql, database, duration } ) {
1334+ console .log (sql, duration );
13291335}
13301336
13311337dc .subscribe (' sqlite.db.query' , onQuery);
13321338
13331339const db = new DatabaseSync (' :memory:' );
13341340db .exec (' CREATE TABLE t (x INTEGER)' );
1335- // Logs: CREATE TABLE t (x INTEGER)
1341+ // Logs: CREATE TABLE t (x INTEGER) <duration>
13361342
13371343const stmt = db .prepare (' INSERT INTO t VALUES (?)' );
13381344stmt .run (42 );
1339- // Logs: INSERT INTO t VALUES (42.0)
1345+ // Logs: INSERT INTO t VALUES (42.0) <duration>
13401346
13411347dc .unsubscribe (' sqlite.db.query' , onQuery);
13421348```
0 commit comments