开发者

mongodb find problem

开发者 https://www.devze.com 2023-03-23 05:41 出处:网络
in user_history collection user_name: john eat : [{food:\'apple\', timestamp:123}, {food:\'chees开发者_JAVA技巧e\', timestamp:80}]

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

0

精彩评论

暂无评论...
验证码 换一张
取 消