Orders
id:1101, supplier:"000822",article:004970,stock:150
id:1102, supplier:"000822",article:004975,stock:100
id:1103, supplier:"000822",article:004650,stock:120
id:1104, supplier:"000822",article:004655,stock:130
id:1105, supplier:"000822",article:004975,stock:140
id:1106, supplier:"000823",article:004980,stock:150
id:1107, supplier:"000823",article:004990,stock:110
In the above data, I want to delete 2 records and with the filter supplier and article.
So I do:
const filter = "{ supplier: '000822', article: 004970}, {supplier: '000822', article: 004975}";
Orders.deleteMany(filter)
.then((result) => {
console.log("result: " + result.deletedCount);
...
})
.catch(err => {
...
});
I get error: {"message":"Parameter "filter" to deleteMany() must be an object, got { supplier: '000822', article: 004970}, {supplier: '000822', article: 004975}"}
What do I wrong?
Wrap the conditions in a top level $or
, using an object instead of a string, like
const filter = {"$or": [
{supplier: '000822', article: 004970},
{supplier: '000822', article: 004975}
]};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.