Home » Php » mongodb – How to search for document by id in Mongo Explorer plugin of php storm

mongodb – How to search for document by id in Mongo Explorer plugin of php storm

Posted by: admin July 12, 2020 Leave a comment

Questions:

I use both robomongo and rockmongo as clients for mongo dbs.. suppose I got a collection called Drivers, then searching by id is quite easy:

db.Driver.find({_id:ObjectId('51118447b38639a960000002')})

I recently installed a mongo plugin for Php Storm, however I couldn’t figure out how to search for a document by id.. the above query fails:

enter image description here

Ideas?

How to&Answers:

As per the support forum, you should query as:

{_id: {$oid: '51118447b38639a960000002'}}

Answer:

{"_id":ObjectId("51118447b38639a960000002")}