Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/node): implement DatabaseSync#applyChangeset() #27967

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Feb 5, 2025

https://nodejs.org/api/sqlite.html#databaseapplychangesetchangeset-options

const sourceDb = new DatabaseSync(':memory:');
const targetDb = new DatabaseSync(':memory:');

sourceDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');
targetDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');

const session = sourceDb.createSession();

const insert = sourceDb.prepare('INSERT INTO data (key, value) VALUES (?, ?)');
insert.run(1, 'hello');
insert.run(2, 'world');

const changeset = session.changeset();
targetDb.applyChangeset(changeset);
// Now that the changeset has been applied, targetDb contains the same data as sourceDb. 

@littledivy littledivy changed the title fix(ext/node): implement DatabaseSync#applyChangeset() fix(ext/node): implement DatabaseSync.applyChangeset() Feb 5, 2025
@littledivy littledivy changed the title fix(ext/node): implement DatabaseSync.applyChangeset() fix(ext/node): implement applyChangeset() for SQLite database Feb 5, 2025
@littledivy littledivy changed the title fix(ext/node): implement applyChangeset() for SQLite database fix(ext/node): implement DatabaseSync#applyChangeset() Feb 5, 2025
Copy link
Contributor

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@littledivy littledivy merged commit ece384c into denoland:main Feb 6, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants