MongoDB Shell - access collection with period in name?

后端 未结 4 1356
醉话见心
醉话见心 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 20:51

    try this instead:

    db["my.collection"].findOne();
    

    you run into the same issue with hyphens or any other name that does not match on [a-zA-Z_$][0-9a-zA-Z_$]

    This limitation comes from valid named for javascript object properties.

提交回复
热议问题