I have a question regarding promises in nodeJS when using Rethindb. This code will give me the results from db first time anything changes, not more.
Lets say I start the script and add a row to the db, the new data will be printed in cmd. But if I add another one, nothing are shown. Something wrong with the way I use the promise? (and no, I dont want to use callback)
Thx!
PushData(r, table)
.then(res=>{
console.log(res);
}
function PushData(r, table){
return new Promise(function(resolve, reject){
r.table(table)
.changes()
.run()
.then(function(cursor){
cursor.on("error", function(err) {
reject(err)
})
cursor.on("data", function(data) {
resolve(data);
})
});
});
}