Skip to content
Advertisement

Tag: mongodb-query

Perform $gte and $lt on the same field _id in MongoDB

db.comments.find({“_id” : {“$gte”: ObjectId(“6225f932a7bce76715a9f3bd”), “$lt”:ObjectId(“6225f932a7bce76715a9f3bd”)}}).sort({“created_datetime”:1}).limit(10).pretty() I am using this query which should give me the current “6225f932a7bce76715a9f3bd” doc, 4 docs inserted before this and 5 docs inserted after this. But currently when i run this query, i get null result. Where am i going wrong ?? Answer I had no other option but to seperate my queries in order to

Query by computed property in python mongoengine

I wondered if it is possible to query documents in MongoDB by computed properties using mongoengine in python. Currently, my model looks like this: When I do for example SnapshotIndicatorKeyValue .objects().first().snapshot, I can access the snapshotproperty. But when I try to query it, it doesn’t work. For example: I get the error `mongoengine.errors.InvalidQueryError: Cannot resolve field “snapshot”“ Is there any

Advertisement