@@ -1457,17 +1457,12 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
1457
1457
* // This won't trigger any callback
1458
1458
* db.run("INSERT INTO users VALUES (2, 'Bob', 1)");
1459
1459
*
1460
- * @param {function|null } callback -
1461
- * Callback to be executed whenever a row changes.
1462
- * Set to `null` to unregister the callback.
1463
- * @param {string } callback.operation -
1464
- * 'insert', 'update', or 'delete'
1465
- * @param {string } callback.database -
1466
- * database where the change occurred
1467
- * @param {string } callback.table -
1468
- * table where the change occurred
1469
- * @param {number } callback.rowId -
1470
- * rowid of the changed row
1460
+ * @param {Database~UpdateHookCallback|null } callback
1461
+ * - Callback to be executed when a row changes. Takes the type of change,
1462
+ * the name of the database, the name of the table, and the row id of the
1463
+ * changed row.
1464
+ * - Set to `null` to unregister.
1465
+ * @returns {Database } The database object. Useful for method chaining
1471
1466
*/
1472
1467
Database . prototype [ "updateHook" ] = function updateHook ( callback ) {
1473
1468
if ( this . updateHookFunctionPtr ) {
@@ -1479,7 +1474,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
1479
1474
1480
1475
if ( ! callback ) {
1481
1476
// no new callback to register
1482
- return ;
1477
+ return this ;
1483
1478
}
1484
1479
1485
1480
// void(*)(void *,int ,char const *,char const *,sqlite3_int64)
@@ -1526,8 +1521,21 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
1526
1521
this . updateHookFunctionPtr ,
1527
1522
0 // passed as the first arg to wrappedCallback
1528
1523
) ;
1524
+ return this ;
1529
1525
} ;
1530
1526
1527
+ /**
1528
+ * @callback Database~UpdateHookCallback
1529
+ * @param {'insert'|'update'|'delete' } operation
1530
+ * - The type of change that occurred
1531
+ * @param {string } database
1532
+ * - The name of the database where the change occurred
1533
+ * @param {string } table
1534
+ * - The name of the database's table where the change occurred
1535
+ * @param {number } rowId
1536
+ * - The [rowid](https://www.sqlite.org/rowidtable.html) of the changed row
1537
+ */
1538
+
1531
1539
// export Database to Module
1532
1540
Module . Database = Database ;
1533
1541
} ;
0 commit comments