5 ways to find a MongoDB document by _id, faster than ever
Here's how you'd do it with your current MongoDB GUI of choice (such as Compass, Robo3T, etc.):
- Choose the connection, database and collection
- Type {_id: '602d3059be20e8435d2c5d53'} or even {_id: new ObjectID('602d3059be20e8435d2c5d53')}
- Submit query
There is, however, a much more convenient way to get this done. Using Mingo.io, you actually have 5 different ways.
Solution no. 1 - _id as the query
Let's assume your _id is in your clipboard. Open your collection and paste the _id into query field and submit it (or press CTRL+Enter).
Solution no. 2 - Paste & Go
Again, let's say your _id is in your clipboard and your collection is open. The Solution no. 1 can be simplified using Mingo's "Paste and Go" function: Press CTRL+G and Mingo will do the rest! You don't even have to be focused in the query field.
Solution no. 3 - Mingo's Finder
If you have your _id, you don't even have to know the collection. Use Mingo's "Finder" (press CTRL+L or open a new tab), paste the _id and choose the database to search in.
Solution no. 4 - Foreign keys
Let's say you are viewing a document containing a foreign key (_id) of a different document. Just click it. Simple as that... Mingo will sift through your DB and open the document in a new tab.
Solution no. 5 - Deep linking
The last solution is the real kicker. Mingo has its own protocol which you can use in your admin or website. Just create a link, for example: mingo://mingo/live/documents/MyCollectionName/602d3059be20e8435d2c5d53