我有看起来像这样的文件:
{
"_id" : ObjectId( "5191651568f1f6000282b81f" ),
"updated_at" : "2013-05-16T09:46:16.199660",
"activities" : [
{
"worker_name" : "image",
"completed_at" : "2013-05-13T21:34:59.293711"
},
{
"worker_name" : "image",
"completed_at" : "2013-05-16T07:33:22.550405"
},
{
"worker_name" : "image",
"completed_at" : "2013-05-16T07:41:47.845966"
}
]
}
我只想找到那些 updated_at 时间大于最后一个活动的文档。完成时间(数组按时间顺序排列)
我目前有这个,但它匹配任何活动[].completed_at
{
"activities.completed_at" : {"$gte" : "updated_at"}
}
谢谢!
更新
好吧,我有不同的工人,每个人都有自己的“completed_at”。
我将不得不按如下方式反转活动:
activities: { image :
last : {
completed_at: t3,
},
items: [
{completed_at: t0},
{completed_at: t1},
{completed_at: t2},
{completed_at: t3},
]
}
并使用此查询:
{
"activities.image.last.completed_at" : {"$gte" : "updated_at"}
}