generators/app/templates/server/api/user(auth)/user.model.js
function validateUniqueName(value, respond) {
  // jshint validthis: true
  var self = this;

  // check for uniqueness of user name
  this.constructor.findOne({name: value}, function (err, user) {
    if (err) {
      throw err;
    }

    if (user) {
      // the searched name is my name or a duplicate
      return respond(self.id === user.id);
    }

    respond(true);
  });
}
function validateUniqueName(value, respond) {
  // jshint validthis: true
  var self = this;

  // check for uniqueness of user name
  this.constructor.findOne({name: value}, function (err, user) {
    if (err) {
      throw err;
    }

    if (user) {
      // the searched name is my name or a duplicate
      return respond(self.id === user.id);
    }

    respond(true);
  });
}
function validateUniqueName ( value , respond ) { // jshint validthis: true var self = this ; // check for uniqueness of user name this . constructor . findOne ( { name : value } , function ( err , user ) { if ( err ) { throw err ; } if ( user ) { // the searched name is my name or a duplicate return respond ( self . id === user . id ) ; } respond ( true ) ; } ) ; }
Validate the uniqueness of the given username

@api private
@param {String} value - The username to check for uniqueness
@param {Function} respond - The callback function
Validate the uniqueness of the given username