user_name: john
eat : [{food:'apple', timestamp:123}, {food:'cheese', timestamp:80}]
user_name: paul
eat : [{food:'melon', timestamp:125}, {food:'bread', timestamp:60}]
user_name: mattew
eat : [{food:'water', timestamp:90}, {food:'pizza', timestamp:91}]
我需要获得时间戳超过100的食物
我的代码:
db.user_history.find({"eat.timestamp":{$gte:100}},{"eat.food":1})
结果:
{'_id': ObjectId('......'),'eat':[{food:'apple'},{food:'cheeza'}]},
{'_id': ObjectId('......'),'eat':[{food:'melon'},{food:'bread'}]}
我想得到的结果:
{'_id': ObjectId('......'), 'eat':{food:apple}},
{'_id': ObjectId('......'), 'eat':{food:melon}}
我怎么能得到这个?