--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en
Am I going to have to write my own validator to check to see if the
email already exists, essentially duplicating the functionality of the
unique index?
On Nov 18, 6:27 am, Aaron Heckmann <aaron.heckm...@gmail.com> wrote:
> yes but not the same way. that error is returned from mongodb so the first
> chance you have to handle it is in your callback.
>
> thing.save(function (err) {
> if (err) {
> if (11000 === err.code || 11001 === err.code) { // or whatever
>
> You'll get 11001 when saving an existing document that now has a unique key
> violation.
> 11000 is for new objects.
>
> On Thu, Nov 17, 2011 at 1:12 PM, Eric Sorenson <
>
>
>
>
>
>
>
>
>
> eric.soren...@dubharmonic.com> wrote:
> > When failing on a unique index, Mongoose returns an error like this:
>
> > { stack: [Getter/Setter],
> > arguments: undefined,
> > type: undefined,
> > message: 'E11000 duplicate key error index: dev.usermodels.$email_1
> > dup key: { : "jeffrey.lebow...@me.com" }',
> > name: 'MongoError',
> > err: 'E11000 duplicate key error index: dev.usermodels.$email_1 dup
> > key: { : "jeffrey.lebow...@me.com" }',