Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2aff403

Browse filesBrowse files
committed
merge master
2 parents 1b161ee + b645ca0 commit 2aff403
Copy full SHA for 2aff403

File tree

1 file changed

+20
-12
lines changed
Filter options

1 file changed

+20
-12
lines changed

‎src/api.js

Copy file name to clipboardExpand all lines: src/api.js
+20-12Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,17 +1457,12 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
14571457
* // This won't trigger any callback
14581458
* db.run("INSERT INTO users VALUES (2, 'Bob', 1)");
14591459
*
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
14711466
*/
14721467
Database.prototype["updateHook"] = function updateHook(callback) {
14731468
if (this.updateHookFunctionPtr) {
@@ -1479,7 +1474,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
14791474

14801475
if (!callback) {
14811476
// no new callback to register
1482-
return;
1477+
return this;
14831478
}
14841479

14851480
// void(*)(void *,int ,char const *,char const *,sqlite3_int64)
@@ -1526,8 +1521,21 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
15261521
this.updateHookFunctionPtr,
15271522
0 // passed as the first arg to wrappedCallback
15281523
);
1524+
return this;
15291525
};
15301526

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+
15311539
// export Database to Module
15321540
Module.Database = Database;
15331541
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.