in user_history collection
user_name: john
eat : [{food:'apple', timestamp:123}, {food:'chees开发者_JAVA技巧e', 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}]
I need to get food which has timestamp over 100
my code:
db.user_history.find({"eat.timestamp":{$gte:100}},{"eat.food":1})
result:
{'_id': ObjectId('......'),'eat':[{food:'apple'},{food:'cheeza'}]},
{'_id': ObjectId('......'),'eat':[{food:'melon'},{food:'bread'}]}
result I want to get:
{'_id': ObjectId('......'), 'eat':{food:apple}},
{'_id': ObjectId('......'), 'eat':{food:melon}}
how could I get this?
I dont think its possible,see the ticket: https://jira.mongodb.org/browse/SERVER-828. Looks like this question is already asked
精彩评论