【发布时间】:2018-10-06 18:34:39
【问题描述】:
我有这样的文件
{
"status": {
"current": 0,
"priority": [{
"operationName": "PHOTO",
"status": "WAITING"
},
{
"operationName": "DESIGN",
"status": "NOTARRIVED"
},
{
"operationName": "COLOR_SEPARATION",
"status": "NOTARRIVED"
}]
}
}
想查询这样的数据
{
"status.priority.$status.current.operationName": {
$in: ['SERVICES', 'PHOTO']
}
}
当我这样查询时
{
"status.priority.0.operationName": {
$in: ['SERVICES', 'PHOTO']
}
}
它返回所需的数据,因为'PHOTO' 是当前操作。
我需要根据数组的一个索引进行查询,这个索引存储在status.current的文档中
有什么提示吗?
更新 问题解决后,我想优化它。
【问题讨论】:
-
请更具体地说明您想要实现的目标
-
想要查询某个索引并且该索引存储在“$status.current”中的 db 中我想在我的查询中使用这个索引,例如
"status.priority.3.operationName"
标签: mongodb mongoose mongodb-query aggregation-framework