How do I get the field that generated a duplicate error (11000).

10 views
Skip to first unread message

Anders Östman

unread,
Feb 10, 2015, 7:37:53 AM2/10/15
to node-mong...@googlegroups.com
When having a unique index, and tries to insert a duplicate I receive a error like this:
"insertDocument :: caused by :: 11000 E11000 duplicate key error index: planpal_dev.services.$client_1_slug_1 dup key: { : ObjectId('54732cc6a5bee54018224f8e'), : \"someText\" }"

I can find the field generating the error with some regex matching. But this seems overly complicated... 
I dont know if this is a driver questions, but if it is... Do you plan to add some easier access to the error field. Like adding a field property to the error:
field: "slug"

Reply all
Reply to author
Forward
0 new messages