-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update $pull on Subcollection-Array doesn't work with collection2 #245
Comments
The following option-argument in the update function solves the problem: {getAutoValues: false} Meteor.methods({
removeSub: function (memberID, subID) {
console.log("MemberID: " + memberID + " | " + "SubID: " + subID);
Members.update(
{_id: memberID},
{$pull:{fee: {_id: subID}}}, {getAutoValues: false});
}
}); It skips the generation of autovalues which is no problem in this case as I want to remove the objects but I think this might lead to a new problem if you want to modify the values of the subdocument. |
It's debatable whether it should be calling autoValue functions when the operator is if (this.operator === '$pull') return; |
When logging
Adding |
Thanks @h2s20 you saved me lots of time! "{ getAutoValues: false }" works. @aldeed "if (this.operator === '$pull') return;" did not work. I am using aldeed:[email protected], aldeed:[email protected] | Many thanks for the great packages! |
Thanks @h2s20 ! same issue. |
Suggested here: Meteor-Community-Packages/meteor-collection2#245
* update cart schema with Product data * add product data to cart update * test fixes * fixing tests Suggested here: Meteor-Community-Packages/meteor-collection2#245 * lint fixes * comment some code
I have a collection Member with an embedded array Fee as subcollection. One Member can have multiple Fees.
If I try to pull a Fee from the array the update function succeeds but nothing happens. The array doesn't get pulled from the array.
I think the problem lies with collection2 because if I use the update function from the mongo shell everythink works fine and if remove collectio2 it also works fine.
The reproduction can be found here on meteorpad: http://meteorpad.com/pad/uE7dmsXgianEB2Ea5/Pull-Subcollection-Array
If you comment out line 52 in common.js - it's possible to remove an object from the array
If you don't comment out line 52 in common.js - the callback of the update function is successfull but nothing happens.
//Members.attachSchema(Schemas.Members);
The schema:
on the client:
method on the server
The text was updated successfully, but these errors were encountered: