I am getting the error while using this query db.a.find({$or:[{"name" : "aekansh"},{"age" : 21}]}).pretty()
as E QUERY [thread1] SyntaxError: invalid property id @(shell):1:11
collection a stores the data as
{ "_id" : 10, "name" : "aekansh" }
{ "_id" : 11, "name" : "ram" }
{ "_id" : ObjectId("59dda15e153802c1d1cf8500"), "name" : "ramu" }
{ "_id" : 12, "nm" : "raj", "age" : 21 }
{ "_id" : ObjectId("59dda1d26b740896d9f067a3"), "nm" : "rj", "age" : 22, "bfff" : "yes" }
{ "_id" : ObjectId("59dda1ea11fc6ddeb8784f7e"), "nm" : "rj1", "age" : 22, "bfff" : "yes" }
I have looked at syntax and I think it is right. Why I am getting the error. Thanx in advance.
Edit- I am using online terminal for MongoDb https://www.jdoodle.com/online-mongodb-terminal
As was mentioned before your query is correct.
If fails on this online terminal it means terminal is buggy.
You have in fact 3 solutions about which I know:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With