Created
March 29, 2017 00:21
-
-
Save aichholzer/6ce25f9f69fcbc38adfe0be6d79cf9bc to your computer and use it in GitHub Desktop.
Parse MongoDB duplicate error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
let err = 'E11000 duplicate key error collection: home.users index: name_1 dup key: { : "francis" }'; | |
let err = 'E11000 duplicate key error collection: home.users index: email.personal_1 dup key: { : "[email protected]" }'; | |
let [i, field, input] = err.match(/index:\s([.a-z]+).*{\s?\:\s?"(.*)"/i); | |
console.log(field, input); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment