Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sqlite3.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Statement.prototype.map = function() {

var isVerbose = false;

var supportedEvents = [ 'trace', 'profile', 'insert', 'update', 'delete' ];
var supportedEvents = [ 'trace', 'profile', 'change'];

Database.prototype.addListener = Database.prototype.on = function(type) {
var val = EventEmitter.prototype.addListener.apply(this, arguments);
Expand Down
10 changes: 9 additions & 1 deletion src/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@ NAN_METHOD(Database::Configure) {
Baton* baton = new Baton(db, handle);
db->Schedule(RegisterProfileCallback, baton);
}
else if (
Nan::Equals(info[0], Nan::New("change").ToLocalChecked()).FromJust()
) {
Local<Function> handle;
Baton* baton = new Baton(db, handle);
db->Schedule(RegisterUpdateCallback, baton);
}
else if (Nan::Equals(info[0], Nan::New("busyTimeout").ToLocalChecked()).FromJust()) {
if (!info[1]->IsInt32()) {
return Nan::ThrowTypeError("Value must be an integer");
Expand Down Expand Up @@ -499,12 +506,13 @@ void Database::UpdateCallback(Database *db, UpdateInfo* info) {
Nan::HandleScope scope;

Local<Value> argv[] = {
Nan::New("change").ToLocalChecked(),
Nan::New(sqlite_authorizer_string(info->type)).ToLocalChecked(),
Nan::New(info->database.c_str()).ToLocalChecked(),
Nan::New(info->table.c_str()).ToLocalChecked(),
Nan::New<Number>(info->rowid),
};
EMIT_EVENT(db->handle(), 4, argv);
EMIT_EVENT(db->handle(), 5, argv);
delete info;
}

Expand Down