简体   繁体   中英

How to create event in Cassandra for every inserts to NodeJS?

I know we use NodeJS with Cassandra using DataStax , but is it possible to create an event in Cassandra for every inserts that is done? We can create triggers in Cassandra but it will not update external system.

There isn't any event builtin the driver that could help you in this case. You can create an event emitter:

var emitter = new events.EventEmitter();

const query = 'INSERT INTO ...';
client.execute(query, params, { prepare: true }, function (err) {
  // ...
  emitter.emit('insert', err);
});

Then, you can listen to the 'insert' event.

emitter.on('insert', function insertEventHandler(err) {
  // ...
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM