Skip to content

Commit

Permalink
doc: add added tag and fix typo sqlite.md
Browse files Browse the repository at this point in the history
PR-URL: nodejs#56012
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
louwers authored and nodejs-github-bot committed Dec 4, 2024
1 parent a897e1c commit d5969ad
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion doc/api/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ around [`sqlite3_prepare_v2()`][].

### `database.createSession([options])`

<!-- YAML
added: v23.3.0
-->

* `options` {Object} The configuration options for the session.
* `table` {string} A specific table to track changes for. By default, changes to all tables are tracked.
* `db` {string} Name of the database to track. This is useful when multiple databases have been added using [`ATTACH DATABASE`][]. **Default**: `'main'`.
Expand All @@ -165,14 +169,18 @@ Creates and attaches a session to the database. This method is a wrapper around

### `database.applyChangeset(changeset[, options])`

<!-- YAML
added: v23.3.0
-->

* `changeset` {Uint8Array} A binary changeset or patchset.
* `options` {Object} The configuration options for how the changes will be applied.
* `filter` {Function} Skip changes that, when targeted table name is supplied to this function, return a truthy value.
By default, all changes are attempted.
* `onConflict` {number} Determines how conflicts are handled. **Default**: `SQLITE_CHANGESET_ABORT`.
* `SQLITE_CHANGESET_OMIT`: conflicting changes are omitted.
* `SQLITE_CHANGESET_REPLACE`: conflicting changes replace existing values.
* `SQLITE_CHANGESET_ABORT`: abort on conflict and roll back databsase.
* `SQLITE_CHANGESET_ABORT`: abort on conflict and roll back database.
* Returns: {boolean} Whether the changeset was applied succesfully without being aborted.

An exception is thrown if the database is not
Expand All @@ -198,15 +206,27 @@ targetDb.applyChangeset(changeset);

## Class: `Session`

<!-- YAML
added: v23.3.0
-->

### `session.changeset()`

<!-- YAML
added: v23.3.0
-->

* Returns: {Uint8Array} Binary changeset that can be applied to other databases.

Retrieves a changeset containing all changes since the changeset was created. Can be called multiple times.
An exception is thrown if the database or the session is not open. This method is a wrapper around [`sqlite3session_changeset()`][].

### `session.patchset()`

<!-- YAML
added: v23.3.0
-->

* Returns: {Uint8Array} Binary patchset that can be applied to other databases.

Similar to the method above, but generates a more compact patchset. See [Changesets and Patchsets][]
Expand Down

0 comments on commit d5969ad

Please sign in to comment.