Having problems with numbers in collection name

838 views
Skip to first unread message

Denis

unread,
Sep 10, 2009, 3:19:32 AM9/10/09
to mongodb-user
Hello,

I have recently started using mongo db for my need.

I'm trying to query a collection named
"summary_from_2009-09-03_06:37", but ending up getting an error.

show collections;

2009
summary_from_2009-09-03_06:37
summary_from_2009-09-03_06:39
system.indexes

db.summary_from_2009-09-03_06:37.find()

Thu Sep 10 15:17:46 JS Error: 09 is not a legal ECMA-262 octal
constant (shell):0
Thu Sep 10 15:17:46 JS Error: SyntaxError: missing ; before statement
(shell):0

For some reason mongo treats collection name as an integer. Should I
parse collection name as a string or otherwise escape it?

Eliot Horowitz

unread,
Sep 10, 2009, 8:32:49 AM9/10/09
to mongod...@googlegroups.com
That's just a shell issue b/c its javascript.
You can do:
db["summary_from_2009-09-03_06:37"].find()
to work around it.
Reply all
Reply to author
Forward
0 new messages