Unable to access MongoDB collection from shell when the name contains '-' -


i have collection named goldenglobes-emotion in mongodb 2.6.9 found can not access collection mongodb shell when ever try access collection, example

db.goldenglobes-emotion.findone() 

i got this:

referenceerror: emotion not defined 

but works when access collection form python pymongo. shell bug? or '-' reserved character?

try db["goldenglobes-emotion"].findone().

the mongodb shell javascript interpreter. javascript not allow hyphens in variable names, because interprets them minus-operator. however, can access object-fields string literals using array-syntax. in case, restriction not apply.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -