Cursor.oberveChange gets multiple calls to changed() for a single update


I am using cursor.oberveChange() to observe what is going on in a Collection.

When doing MyCollection.update(id, { $set: { field1: value1, field2: value2 } }), I end up with two calls to the changed() callback: one for field1, another one for field2.

Is it the expected behavior? If it is, is there a way I can know when fields are set together?


I believe that should only be called once per document changed, unless I’m mistaken.

Does your case sound like this? If so, looks like that should be fixed if you’re using the most current release.

Also, per the docs, observeChanges returns only the changed properties, whereas observe returns the entire old and new document with all its fields. So observeChanges should be what you’re looking for to see what specific fields change.

Any chance you could paste the snippets including your observe code and update code?


Here is the update code:

    { $set: {	 title: title, lock: { contrId: null, serverTime: new Date(0) } }

And the observeChange code:

		Subsecs.find({ projectId: projectId }).observeChanges(			{
    			added: function(id, subsec)	 { 
        manageLockAndRole(self, id, subsec); 	
        subsec._id = id;
    			changed: function(id, fields) 				{
    				    manageLockAndRole(self, id, fields);
        self.localSubsecs.update(id, { $set: fields });
    			removed: function(id) {

One update triggers two calls to the changed() callback, the first one for lock, the second one for title.