MongoDB-Escape dots '.' in map key
If we have a collection named "test-core". then we do the operation using script directly, like:
db.test-core.ensureIndex( { userid: 1 } )
The server will throw exception: ReferenceError: core is not defined
This is because the character '-' inside the collection name is not correctly read.
The way to resolve is :
db["test-core"].ensureIndex( { userid: 1 } )
No comments:
Post a Comment