我有一個看起來是這樣的文件:查詢與時間戳陣列
{
"_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時間比最後 activities.completed_at時間的情況下(陣列是按時間順序)
我現在有這一點,但它任何活動[]匹配。completed_at
{
"activities.completed_at" : {"$gte" : "updated_at"}
}
謝謝!
更新
嗯,我有不同的工人,每個人都有自己的 「completed_at」。
我將不得不顛倒activites如下:
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"}
}
我需要下拉到JavaScript? – rbp