Search code examples
rethinkdbrethinkdb-javascript

changes() not called when inserting a document


I have a problem with the changelog function of rethinkdb. There is no console output, when adding a document to the collection. BUT "changes" is outputted once after starting my application via node app.js, why is that so? Any help is appreciated.

// rethinkdb connection
var connection = null;
r.connect({ db: 'bc', host: 'localhost', port: 1337}, function(err, conn) {
    if(err) throw err;

    connection = conn;
    observeBets();
});


function observeBets() {
    r.table('bets').changes().run(connection, function(err, betsCursor) {
        if (err) throw err;

        console.log("changes");
    });
}

Insert via

var bet = {
    bet: "test",
    userID: 213
};
r.table('bets').insert(bet);

Solution

  • I think you need to be iterating over betsCursor.