Basically the question is simple:
How can I issue a query on a collection, which starts with _?
For example if I have 2 collections test
and _test
, and I am trying db.test.findOne()
and db._test.findOne()
in mongoshell
the first one is working as intended, whereas the second tells me TypeError: db._testhas no properties (shell):1
Place it in quotes and use the getCollection method. See this article
Example To create a collection _foo and insert the { a : 1 } document, use the following operation:
db.getCollection("_foo").insert( { a : 1 } )
To perform a query, use the find() method, in as the following:
db.getCollection("_foo").find()
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