Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference a collection name with "." in Mongo db? [duplicate]

I have a mongo DB, in the mongo shell, when I run "show collections", it returns the collection with dot in the collection name like

a.1
a.2
a.3

How I refer it in command like

db.a.1.find()

the above returns SyntaxError: missing ; before statement

like image 760
Russel Yang Avatar asked Oct 18 '25 14:10

Russel Yang


1 Answers

figure it out. wrapping it in [ ]. basic javascript knowledge.

db["a.1"].find()
like image 144
Russel Yang Avatar answered Oct 20 '25 07:10

Russel Yang