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
Post a Comment