简体   繁体   English

如何在mongoDB中使用nin和regex

[英]how to use nin and regex in mongoDB

How to use nin and regex in mongoDB? 如何在mongoDB中使用nin和regex?

I want to find document using nin and regex 我想使用Nin和正则表达式查找文档

but nin does not work! 但是nin不起作用!

Query: 查询:

{ "$and" : [ 

{ "id" : { "$nin" : [ "529653cb5bc5b0e42d339bd3" , "529653cb5bc5b0e498339bd3"]}} ,

{ "content" : { "$regex" : "(?i)apple" , "$options" : "i"} }

] }

Should I using mongo subquery? 我应该使用mongo子查询吗?

Your problem could be multiple things depending upon the error you're getting. 根据您遇到的错误,您的问题可能是多方面的。

But a quick examination of your query suggests it could be your use of the "id" field. 但是快速检查一下您的查询,可能是您使用了“ id”字段。 The primary key field in all documents is "_id". 所有文档中的主键字段均为“ _id”。 Your query uses the field "id" but you're probably trying to query the field "_id". 您的查询使用字段“ id”,但您可能正在尝试查询字段“ _id”。

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

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