From 332d765e73dfc6d610b0a38d6ede7fda91abe561 Mon Sep 17 00:00:00 2001 From: Antoine Grandchamp Date: Mon, 9 Jul 2018 10:11:53 -0400 Subject: [PATCH] Handle $unset in "changed" event (#317) * Handle $unset in "changed" event * Prettify --- src/Meteor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Meteor.js b/src/Meteor.js index 30972ed..20be280 100644 --- a/src/Meteor.js +++ b/src/Meteor.js @@ -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, }); });