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

Notification callbacks #419

Closed
toomim opened this issue Feb 24, 2015 · 15 comments
Closed

Notification callbacks #419

toomim opened this issue Feb 24, 2015 · 15 comments

Comments

@toomim
Copy link

toomim commented Feb 24, 2015

Sqlite features data-change notification callbacks that tell you when a particular table has been modified. This is super useful for writing realtime, reactive web servers, that notify all connected clients when data has changed. But there's no support for this notification API in node-sqlite3.

Would bindings for this be easy to add to node-sqlite3? I understand that sqlite runs in a different thread, so I imagine that the thread would need to communicate with the v8 thread, to call a notification method, and just pass it these parameters:

  • A string "insert", "delete", or "update" describing the type of change
  • The database
  • The table name
  • The rowid of the row
@carbureted
Copy link

+1, this would be great to have. Polling my db way too much right now..

@JohnKossa
Copy link

Already added in commit b8f718c.

That being said, this doesn't appear to be anywhere in the README or the API.

@carbureted
Copy link

Huh, cool. I can't test right now, but it looks like it would be used with something like the following?

var db = new sqlite3.Database(file, ['sqlite3.OPEN_READONLY']);

db.on('insert', function() {
console.log('inserted!')
})

@sohailsomani
Copy link

That commit is missing a corresponding change in Database::Configure as far as I can tell.

@devlesedi
Copy link

Is there a solution for this? On my web app I want to listen to data changes.

@alajmo
Copy link

alajmo commented Mar 17, 2016

This feature would be really nice to have.

@ushalin
Copy link

ushalin commented Feb 8, 2018

Any update on this feature?

@natew
Copy link

natew commented Mar 19, 2018

Would be awesome to see!

@bpasero
Copy link
Contributor

bpasero commented Oct 5, 2018

I am able to get the events working (with this change: bpasero@1f1e2c8). However, this event does NOT work when multiple connections are used across multiple processes. I believe they only work for a single connection.

@vishnuprasad-95
Copy link

Any update on this?

@pwner4once
Copy link

pwner4once commented Feb 4, 2021

Any update on this feature? It seems rather useful to have but why is this fallen on silent ears?

@daniellockyer
Copy link
Member

There is an open PR to fix the implementation here: #1267

@maxpert
Copy link

maxpert commented Aug 18, 2022

Merge it please 😢 I desperately need it!

@daniellockyer
Copy link
Member

The PR is merged and will be released shortly 🙂

@maxpert
Copy link

maxpert commented Sep 14, 2022

🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests