You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
I'm reading Mongoose doc. I did not find any info about configuring err msg for unique.
I'm running Ubuntu 14.04 with MongoDB 3.2.3. Nodejs is v4.3.2
I attached a screenshot. This is not good to display such a detailed error.
I tested with clean enviroment in vagrant. The only difference is: MongoDB 3.0.9 and 3.2.3.
I wonder where does the sentence "Email already exists" or '11000 duplicate key error collection: mean-test.users index: username already exists' to be 'Username already exists' come from?
I enabled the debug mode of mongoose. I tested with both Mongo 3.0 and 3.2.
The query generated by mongoose is the same (execept salt).
Then I execute the insert query manually in Mongo 3.0 and 3.2.
The output is also the same.
I figured out the problem.
If you upgrade mongodb from 3.0 to 3.2, there is no issue because you still use MMAPv1 engine.
But if you install new mongodb 3.2, there is a problem because you use new WiredTiger engine.
The output of these 2 engine is slightly different. MMAPv1
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 11000,
"errmsg" : "E11000 duplicate key error index: mean-dev.users.$email_1 dup key: { : "[email protected]" }"
}
})
The new WiredTiger engine is introduced in MongoDB 3.2.
It changes the output errmsg format for violation of unique index.
This commit adds support for the new format.
Fixesmeanjs#1245
The new WiredTiger engine is introduced in MongoDB 3.2.
It changes the output errmsg format for violation of unique index.
This commit adds support for the new format.
Fixesmeanjs#1245
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
@trendzetter @ilanbiala
I'm reading Mongoose doc. I did not find any info about configuring err msg for unique.
I'm running Ubuntu 14.04 with MongoDB 3.2.3. Nodejs is v4.3.2
I attached a screenshot. This is not good to display such a detailed error.
I tested with clean enviroment in vagrant. The only difference is: MongoDB 3.0.9 and 3.2.3.
I wonder where does the sentence "Email already exists" or '11000 duplicate key error collection: mean-test.users index: username already exists' to be 'Username already exists' come from?
I enabled the debug mode of mongoose. I tested with both Mongo 3.0 and 3.2.
The query generated by mongoose is the same (execept salt).
Then I execute the insert query manually in Mongo 3.0 and 3.2.
The output is also the same.
Mongo 3.0
Mongoose: users.insert({ salt: 'RphFQ5BmRcgAxoa9vAaCTQ==', displayName: 'Test User', provider: 'local', username: 'testuser', _id: ObjectId("56d767da3ccc59b408859f90"), created: new Date("Wed, 02 Mar 2016 22:23:22 GMT"), roles: [ 'user' ], profileImageURL: 'modules/users/client/img/profile/default.png', password: '9WsKha9q20AQdR6jYfBIv9LSYg5Qsfa+MTLFka0KmazFcGKh9VKVxFm1ft3S2AjqIVJorN4ihEz1nOoH6U22UA==', email: '[email protected]', lastName: 'User', firstName: 'Test', __v: 0 })
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 11000,
"errmsg" : "E11000 duplicate key error index: mean-dev.users.$username_1 dup key: { : "testuser" }"
}
})
Mongo 3.2
Mongoose: users.insert({ salt: 'd4SiQVR3xDk0rqHQ3dajNw==', displayName: 'Test User', provider: 'local', username: 'testuser', _id: ObjectId("56d7684543b5be880b8aedd7"), created: new Date("Wed, 02 Mar 2016 22:25:09 GMT"), roles: [ 'user' ], profileImageURL: 'modules/users/client/img/profile/default.png', password: 'hsKel5Gew/IVqoo8oynaOFayV35sKP07xbcApvVosAhILPg99l0ccv74+mu7k14+ph2LJpxQ5ntPsDBTMtYhag==', email: '[email protected]', lastName: 'User', firstName: 'Test', __v: 0 })
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 11000,
"errmsg" : "E11000 duplicate key error index: mean-dev.users.$username_1 dup key: { : "testuser" }"
}
})
I think mongodb does not change error reply. I wonder whether mongoose or other plugin changes the err msg behavior.
The text was updated successfully, but these errors were encountered: