TypeError: Cannot call method 'find' of undefined on executing query on collection with numeric name

305 views
Skip to first unread message

Rakesh Bhatt

unread,
Apr 25, 2015, 8:27:57 AM4/25/15
to mongod...@googlegroups.com
Hi,

I have currently installed mongodb on windows. I had create an collection with numeric name 12345. When i try to execute query on collection 12345

db.12345.find()

it shows me error: SyntaxError: Unexpected number

After some search i came with working solution

db['12345'].find()

Now it is showing me error TypeError: Cannot call method 'find' of undefined

What is the problem ? Should i use non numeric collection as non numeric collection showing me problem

Thanks in advance

Asya Kamsky

unread,
Apr 25, 2015, 9:56:01 PM4/25/15
to mongodb-user
Try this syntax:

db.getCollection("12345").find()

That should work if the collection exists in that db.

Asya


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/59d3bed3-77fe-45ab-a1f7-b1c77ca97498%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MongoDB World is back! June 1-2 in NYC. Use code ASYA for 25% off!
Reply all
Reply to author
Forward
0 new messages