I have a document {_id: abc, orderdate:(ISO date), quantity:10}
and I am trying to come up with query in Java where we search for all documents with orders in a given month whose quantity
is > 5
Eg: select * from documents where month(orderdate)=Jan and quantity>5
Can you please help me write this query in Java?
After going thru Search by month in MongoDB
I learnt about $expr from
db.customer.find({ "$expr": { "$eq": [{ "$month": "$bday" }, 9] } })
and converted toand then get java code using
Document.parser("db.getCollection('custoer').find({"$and":[{"$expr": { "$eq": [{ "$month": "$bday" }, 9] }},{"firstName":"John"}]})")
at the end java code looks like
Filters.and(Arrays.asList(Filters.expr(new Document().append("$in", Arrays.asList(new Document().append("$month", "$bday"),9))),Filters.eq("firstName","John")))