@@ -1935,48 +1935,6 @@ This allows subscribers to observe every SQL statement executed without
19351935modifying the database code itself. Tracing is zero-cost when there are no
19361936subscribers.
19371937
1938- ``` cjs
1939- const dc = require (' node:diagnostics_channel' );
1940- const { DatabaseSync } = require (' node:sqlite' );
1941-
1942- function onQuery ({ sql, database, duration }) {
1943- console .log (sql, duration);
1944- }
1945-
1946- dc .subscribe (' sqlite.db.query' , onQuery);
1947-
1948- const db = new DatabaseSync (' :memory:' );
1949- db .exec (' CREATE TABLE t (x INTEGER)' );
1950- // Logs: CREATE TABLE t (x INTEGER) <duration>
1951-
1952- const stmt = db .prepare (' INSERT INTO t VALUES (?)' );
1953- stmt .run (42 );
1954- // Logs: INSERT INTO t VALUES (42.0) <duration>
1955-
1956- dc .unsubscribe (' sqlite.db.query' , onQuery);
1957- ```
1958-
1959- ``` mjs
1960- import dc from ' node:diagnostics_channel' ;
1961- import { DatabaseSync } from ' node:sqlite' ;
1962-
1963- function onQuery ({ sql, database, duration }) {
1964- console .log (sql, duration);
1965- }
1966-
1967- dc .subscribe (' sqlite.db.query' , onQuery);
1968-
1969- const db = new DatabaseSync (' :memory:' );
1970- db .exec (' CREATE TABLE t (x INTEGER)' );
1971- // Logs: CREATE TABLE t (x INTEGER) <duration>
1972-
1973- const stmt = db .prepare (' INSERT INTO t VALUES (?)' );
1974- stmt .run (42 );
1975- // Logs: INSERT INTO t VALUES (42.0) <duration>
1976-
1977- dc .unsubscribe (' sqlite.db.query' , onQuery);
1978- ```
1979-
19801938[ BoundedChannel Channels ] : #boundedchannel-channels
19811939[ TracingChannel Channels ] : #tracingchannel-channels
19821940[ `'uncaughtException'` ] : process.md#event-uncaughtexception
0 commit comments