Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
657 stars 92 forks source link

`$pull` calls .update hook twice, once with null, once as it should be #175

Open turbobuilt opened 8 years ago

turbobuilt commented 8 years ago

Hello,

First, thanks for a great plugin!

Now to the problem: When I run a $pull command in mongodb, a strange thing happens. It calls my .update collection hook twice. The first time, with a null in place of the object, and the second time with the null removed.

First time

//this.previous
{
    _id:"dsflaklfjslj",
    myArr:[{_id:aeeoeio",val:"23"}]
}
//doc
{
    _id:"dsflaklfjslj",
    myArr:[null]
}

Now second time it is called

//this.previous
{
    _id:"dsflaklfjslj",
    myArr:[null]
}
//doc
{
    _id:"dsflaklfjslj",
    myArr:[]
}

This looks like a bug - it should only be called once with the null removed.

Thanks!