Search code examples
mongodbcollectionsnaming

Copying a collection whose name is a number in MongoDB


i habe named a collection 222. I want to copy that one but it doesn't work.

db.222.find()
2020-08-21T13:37:24.355+0200 E QUERY    [js] SyntaxError: missing ; before statement @(shell):1:2

I am getting that error message. There should be a way to call columns that starts with a number like in other languages, but I don't know how...

hopefully someone had the same problem earlier and can help me.

best reagards and thanks!


Solution

  • You can use the getCollection function.

    db.getCollection("222").find()