Skip to content

Commit

Permalink
Add getRowsModified to worker (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
scola84 authored Oct 29, 2024
1 parent fbc1f07 commit a311180
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ function onModuleReady(SQL) {
id: data["id"],
results: db.exec(data["sql"], data["params"], config)
});
case "getRowsModified":
return postMessage({
id: data["id"],
rowsModified: db.getRowsModified()
});
case "each":
if (db === null) {
createDb();
Expand Down
3 changes: 3 additions & 0 deletions test/test_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ exports.test = async function test(SQL, assert) {
assert.strictEqual(table.values[2][1], 'c', 'Reading string');
assert.deepEqual(obj2array(table.values[2][2]), [0x00, 0x44], 'Reading BLOB byte');

data = await worker.postMessage({ action: 'getRowsModified' });
assert.equal(data.rowsModified, 1, 'Number of changed rows')

data = await worker.postMessage({ action: 'export' });
var header = "SQLite format 3\0";
var actual = "";
Expand Down

0 comments on commit a311180

Please sign in to comment.