Skip to content

Commit b90ac09

Browse files
authored
Merge pull request #893 from powersync-js/polish/jsdoc-mutation-returning-note
Add JSDoc comment to mutation return value behavior
2 parents 93703a0 + 2844b1d commit b90ac09

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/common/src/client/AbstractPowerSyncDatabase.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,10 @@ SELECT * FROM crud_entries;
813813
* Execute a SQL write (INSERT/UPDATE/DELETE) query
814814
* and optionally return results.
815815
*
816+
* When using the default client-side [JSON-based view system](https://docs.powersync.com/architecture/client-architecture#client-side-schema-and-sqlite-database-structure),
817+
* the returned result's `rowsAffected` may be `0` for successful `UPDATE` and `DELETE` statements.
818+
* Use a `RETURNING` clause and inspect `result.rows` when you need to confirm which rows changed.
819+
*
816820
* @param sql The SQL query to execute
817821
* @param parameters Optional array of parameters to bind to the query
818822
* @returns The query result as an object with structured key-value pairs

packages/common/src/db/DBAdapter.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ import { BaseListener, BaseObserverInterface } from '../utils/BaseObserver.js';
1616
export type QueryResult = {
1717
/** Represents the auto-generated row id if applicable. */
1818
insertId?: number;
19-
/** Number of affected rows if result of a update query. */
19+
/**
20+
* Number of affected rows reported by SQLite for a write query.
21+
*
22+
* When using the default client-side [JSON-based view system](https://docs.powersync.com/architecture/client-architecture#client-side-schema-and-sqlite-database-structure),
23+
* `rowsAffected` may be `0` for successful `UPDATE` and `DELETE` statements.
24+
* Use a `RETURNING` clause and inspect `rows` when you need to confirm which rows changed.
25+
*/
2026
rowsAffected: number;
2127
/** if status is undefined or 0 this object will contain the query results */
2228
rows?: {

0 commit comments

Comments
 (0)