-
Notifications
You must be signed in to change notification settings - Fork 2k
Conversation
Was that changed in Mongoose 4.0? Is there a way to make sure these are the 3.8 docs? |
Nope, it was boolean also with 3.x: http://mongoosejs.com/docs/3.8.x/docs/api.html#schematype_SchemaType-unique The irritating bit is that currently at signup controller, Mean.js doesn't shout out if it's the email that's unique or the username. It just shouts "Unique field already exist", which isn't very helpful for the user. Mongoose-unique-validator tries to solve the issue, but I don't know if that's a great package. |
@lirantal thoughts on why it was a string? |
I don't recall on why this was set as string, but it seems a reasonable fix to update to boolean so I'll merge if it LTY |
Lgtm. |
Volá, now someone made a plugin that adds support to Read more: Automattic/mongoose#2284 (comment) Plugin: https://www.npmjs.com/package/mongoose-beautiful-unique-validation |
@simison Is this something that still needs to get changed in the 0.4 version? Or are we leaving it as a string to represent the error message? |
@simison is that a bug though? it does work today because there's a validation attached to that specific field. Correct me if I'm wrong. |
I think it "works" now with a string because it returns true, but it doesn't work as expected since that message won't be sent with the error. I recently implemented a solution elsewhere with that mongoose-beautiful-unique-validation package so I think I could send a PL a bit later. Let's leave the string there for now and it'll then just work with mongoose-beautiful-unique-validation. Closing this. |
@simison I think we may also run into some issues when we upgrade to Mongoose Mongoose 4.1.x, which would definitely be awesome when we start using promises instead of callbacks. |
As it should be: http://mongoosejs.com/docs/api.html#schematype_SchemaType-unique