Dio*_*lor 15 mongodb pymongo mongodb-query
好一个字段匹配我运行:
db.bios.find( { "Country":"Netherlands" } )
Run Code Online (Sandbox Code Playgroud)
我如何携带所有文件而不是带文件"Country":"Netherlands"?
也可以带上所有文件,但没有2个国家?
Yev*_*yev 25
使用$ nin运算符
例如:
db.bios.find( { Country: { $nin: ["Country1", "Country2"] } } )
Run Code Online (Sandbox Code Playgroud)
而NE $只是一个国家:
db.bios.find( { Country: { $ne: "Country1" } } )
Run Code Online (Sandbox Code Playgroud)
您可以将$ne-operator (not-equal) 用于单个值。
db.bios.find( { "Country": { $ne: "Netherlands" } } );
Run Code Online (Sandbox Code Playgroud)
要排除多个值,您可以使用$nin (not-in) 运算符,它允许您传递一组值:
db.bios.find( { "Country": { $nin: [ "Netherlands", "Belgium", "Luxembourg" ] } );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11480 次 |
| 最近记录: |