Answer the question
In order to leave comments, you need to log in
How to make a selection for deletion in mongoDB from Meteor.JS?
Greetings! I'm going through a tutorial on the Meteorjs website on how to create a Todo application, and in the process there was a problem, or rather, with a request to delete all records where checked is true (the code is attached).
Template.users.events({
"click .toggle-checked": function() {
Users.update(this._id, {$set: {checked: ! this.checked}});
},
"click .delete": function() {
Users.remove(this._id);
},
"click .alldel": function() {
// так не работает, по идее должно вот так быть Users.remove(checked: true); но и так не работает
Users.remove({}, {$where: {checked: true}});
}
});
Answer the question
In order to leave comments, you need to log in
$where doesn't work that way. It takes either a string or a function: $where: 'return this.checked'
either $where: function () {return this.checked}
. $where has low performance, so it is recommended to use it only if there is no other way .
Not to mention that the condition should still be the first argument, not the second.
Users.remove(checked: true)If you wrote it directly, then this is a syntax error, it should be:
Users.remove({checked: true})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question