Reputation: 222461
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
Upvotes: 5
Views: 692
Reputation: 6738
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()
Upvotes: 5