MongoDB Shell - access collection with period in name?

后端 未结 4 1387
醉话见心
醉话见心 2020-12-30 20:43

I have found a collection in one of our MongoDB databases with the name my.collection.

Is there a way to access this collection from the MongoDB shell,

4条回答
  •  我在风中等你
    2020-12-30 21:02

    Another foolproof method is:

    db.getCollection("_SCHEMA").find()
    

    While in the case of a underscore in the name, still cause a error with @Laura answer:

    > db["_SCHEMA"].find()
    2016-07-18T17:44:16.948+0200 E QUERY    [thread1] TypeError: db._SCHEMA is undefined :
    @(shell):1:1
    

提交回复
热议问题