MongoDB: Can't canonicalize query: BadValue unknown operator -
the data given follows:
{ "_id" : { "$oid" : "546b79a2e4b0f7bfbaa97cc7" }, "title" : "eyewitness: highlands, scotland", "description" : "photographs guardian eyewitness series", "timestamp" : "14/11/2014", "category" : "news", "url" : "http://www.theguardian.com/world/picture/2014/nov/14/1", "source" : "http://www.theguardian.com/", "mainstory" : "\n", "keywords" : [ "wildlife", "scotland" ] }
but when use following command find something, error comes out
db.guardian.find({ "_id": {"$oid": '546b79a2e4b0f7bfbaa97cc7'}})
how can find document specific $oid
.
you need convert id string objectid this:
db.guardian.find({ "_id": objectid("546b79a2e4b0f7bfbaa97cc7") })
the reason being { "$oid" : "546b79a2e4b0f7bfbaa97cc7"}
same objectid("546b79a2e4b0f7bfbaa97cc7")
in different format.
refer docs more details.
Comments
Post a Comment