5

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

Adel Khayata
  • 2,717
  • 10
  • 28
  • 46
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753

1 Answers1

5

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()
What Would Be Cool
  • 6,204
  • 5
  • 45
  • 42