@@ -1378,27 +1378,33 @@ are no subscribers.
13781378
13791379### Channel ` sqlite.db.query `
13801380
1381- The message published to this channel is a {string} containing the expanded
1382- SQL with bound parameter values substituted. If expansion fails, the source
1383- SQL with unsubstituted placeholders is used instead.
1381+ The message published to this channel is an {Object} with the following
1382+ properties:
1383+
1384+ * ` sql ` {string} The expanded SQL with bound parameter values substituted.
1385+ If expansion fails, the source SQL with unsubstituted placeholders is used
1386+ instead.
1387+ * ` database ` {DatabaseSync} The ` DatabaseSync ` instance that executed the
1388+ statement.
1389+ * ` duration ` {number} The estimated statement run time in nanoseconds.
13841390
13851391``` cjs
13861392const dc = require (' node:diagnostics_channel' );
13871393const { DatabaseSync } = require (' node:sqlite' );
13881394
1389- function onQuery (sql ) {
1390- console .log (sql);
1395+ function onQuery ({ sql, database, duration } ) {
1396+ console .log (sql, duration );
13911397}
13921398
13931399dc .subscribe (' sqlite.db.query' , onQuery);
13941400
13951401const db = new DatabaseSync (' :memory:' );
13961402db .exec (' CREATE TABLE t (x INTEGER)' );
1397- // Logs: CREATE TABLE t (x INTEGER)
1403+ // Logs: CREATE TABLE t (x INTEGER) <duration>
13981404
13991405const stmt = db .prepare (' INSERT INTO t VALUES (?)' );
14001406stmt .run (42 );
1401- // Logs: INSERT INTO t VALUES (42.0)
1407+ // Logs: INSERT INTO t VALUES (42.0) <duration>
14021408
14031409dc .unsubscribe (' sqlite.db.query' , onQuery);
14041410```
@@ -1407,19 +1413,19 @@ dc.unsubscribe('sqlite.db.query', onQuery);
14071413import dc from ' node:diagnostics_channel' ;
14081414import { DatabaseSync } from ' node:sqlite' ;
14091415
1410- function onQuery (sql ) {
1411- console .log (sql);
1416+ function onQuery ({ sql, database, duration } ) {
1417+ console .log (sql, duration );
14121418}
14131419
14141420dc .subscribe (' sqlite.db.query' , onQuery);
14151421
14161422const db = new DatabaseSync (' :memory:' );
14171423db .exec (' CREATE TABLE t (x INTEGER)' );
1418- // Logs: CREATE TABLE t (x INTEGER)
1424+ // Logs: CREATE TABLE t (x INTEGER) <duration>
14191425
14201426const stmt = db .prepare (' INSERT INTO t VALUES (?)' );
14211427stmt .run (42 );
1422- // Logs: INSERT INTO t VALUES (42.0)
1428+ // Logs: INSERT INTO t VALUES (42.0) <duration>
14231429
14241430dc .unsubscribe (' sqlite.db.query' , onQuery);
14251431```
0 commit comments