Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好的,我需要一种快速的方法来使用 mongoDB 执行以下操作
我正在寻找一个查询来搜索集合中的水果或蔬菜列中没有 Apple 一词的任何东西
这里等
{ "fruit":"apple" },{ "fruit":"orange" },{ "fruit":"banana" }
您可能要使用的运算符是$nin(“不在”):
db.market.find({ 'fruit': {$nin:['apple']}, 'veg': {$nin:['apple']} })
您也可以使用$not来否定标准 where 条件。