1

in user_history collection

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}]

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?

1 Answer 1

1

I dont think its possible,see the ticket: https://jira.mongodb.org/browse/SERVER-828. Looks like this question is already asked

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.