好的,对于一个字段匹配,我运行:
db.bios.find( { "Country":"Netherlands" } )我怎样才能带上所有的文档而不带"Country":"Netherlands"的文档?
还有,有没有可能带上所有的证件,但没有两个国家?
发布于 2013-08-26 16:32:15
使用$nin operator
例如:
db.bios.find( { Country: { $nin: ["Country1", "Country2"] } } )和$ne,只针对一个国家:
db.bios.find( { Country: { $ne: "Country1" } } )发布于 2013-08-26 16:34:19
您可以对单个值使用$ne-operator (不等于)。
db.bios.find( { "Country": { $ne: "Netherlands" } } );要排除多个值,可以使用$nin (not-in)运算符,它允许您传递一个值数组:
db.bios.find( { "Country": { $nin: [ "Netherlands", "Belgium", "Luxembourg" ] } );https://stackoverflow.com/questions/18439612
复制相似问题