Is there a way to find which conditions failed in a find
query.
Consider the following schema:
{
a: String,
b:[{
b_id: String
}]
}
I am searching for a record which matches 'a' and a 'b_id'. But if 'a' does not match then I have a different action to take and if 'b_id' is not found, then a different action.
Right now I am looking for a document with 'a' and then looping through the result to match for 'b_id'. This is not a efficient solution for me since the loop can easily go over tens of thousand times.
Is there a way to find out which condition failed to match or any other efficient way of doing this?
在mongo中,您具有可以运行的collection.find().explain()
函数,它将解释所有计划以及如何构建查询,以什么顺序排列以及其他有用的信息。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.