meteor-roles: createRole : E11000 uncatched with mongo v3.2.4 results in a failing unlessExists option
Reason is the matching expression /E11000 duplicate key error index: ([^ ]+)/
missing the message returned by this 3.2.4 mongo version : "E11000 duplicate key error collection: XXX.roles index: _id_ dup key: { : "ADMIN" }"
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 21 (20 by maintainers)
Commits related to this issue
- Made checking for duplicate key work on MongoDB 3.2. Fixes #185. — committed to Meteor-Community-Packages/meteor-roles by mitar 8 years ago
You know what? We should probably be using
upsert
with a$setOnInsert
clause instead ofinsert
. That way we wouldn’t even get an error if something already exists. That’s the top answer for a similar question on SO: http://stackoverflow.com/questions/2801008/mongodb-insert-if-not-exists