arnoutaertgeerts/ng-pouch

Ensure unique displayname and email

Opened this issue · 0 comments

Two options:

The first option uses CouchDB and stores a preliminary document and queries a view afterwards. This option follows this question.

The second option uses MongoDB to keep track of the unique fields:

var User = new Schema({ 
    name: {type: String, unique: true },
    email: {type: String, unque: true}
});

function save(user) {
    mongo.save(user).then(function() {
        //No duplicates
        couch.save(user);
    }).catch(function(err) {
        //Duplicate exist!
        responseError(err)
    })
}