Skip to content

Commit

Permalink
Handle $unset in "changed" event (#317)
Browse files Browse the repository at this point in the history
* Handle $unset in "changed" event

* Prettify
  • Loading branch information
AntoineGrandchamp authored and charpeni committed Jul 9, 2018
1 parent 0ac0058 commit 332d765
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Meteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,18 @@ module.exports = {
});

Data.ddp.on('changed', message => {
const unset = {};
if (message.cleared) {
message.cleared.forEach(field => {
unset[field] = null;
});
}

Data.db[message.collection] &&
Data.db[message.collection].upsert({
_id: message.id,
...message.fields,
...unset,
});
});

Expand Down

0 comments on commit 332d765

Please sign in to comment.