简体   繁体   English

使用$ not条件更新文档

[英]Update documents with $not criteria

I would like to update with mongoose documents where the criteria is not something, I thought about something like this: 我想用猫鼬的文档更新那些没有标准东西,我想到了这样的东西:

Candidate.update({candidateID: $not: {req.body.candidateID} }, {status: 'REJECTED'})

I don't think that it would work because $not works with <operator-expression> .. 我认为这不会起作用,因为$not<operator-expression>

How can I achieve to update something like this? 我该如何实现更新这样的事情?

In update query, the first part is to documents to be updated, and secand part is to specify the changes to the document given. 在更新查询中,第一部分是要更新的文档,第二部分是指定对给定文档的更改。 In you case you have to use the operator $set 在这种情况下,您必须使用运算符$ set

 Candidate.update({candidateID: $not: {req.body.candidateID} }, {$set:{status: 'REJECTED'}})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM