Mongo/Meteor cursor update event


#1

Hi All,

I am using Angular/Meteor to build a chat app.

Question
Is there a way to detect when there are changes to the MongoDB Cursor? Is there some event triggered when a row is added?

In my chat app, if I message another user, the new chat appears in the list (i.e. the MongoDB is updated), but I need to detect this update, so I can populate the new chat with the username, etc. If I refresh the page it is displayed correctly, but I need to be able to do this dynamically.

Thank you


#2

SOLUTION

        this.chats.observeChanges({
          added: function (id, object) {
            // This code runs when a new object "object" was added to collection.
          }
        });