samples/sample3/handlers/projects.js
function verifyProjectNameDoesNotExist(req, res, next) {
  var projectName = req.body.name.toLowerCase();
  var dataStore = req.app.dataStore;

  // Get all project REST resources
  dataStore.getCollection('/projects', function(err, resources) {
    var alreadyExists = resources.some(function(resource) {
      return resource.data.name.toLowerCase() === projectName;
    });

    if (alreadyExists) {
      // The ID already exists, so send an HTTP 409 (Conflict)
      res.sendStatus(409);
    }
    else {
      next();
    }
  });
}
function verifyProjectNameDoesNotExist(req, res, next) {
  var projectName = req.body.name.toLowerCase();
  var dataStore = req.app.dataStore;

  // Get all project REST resources
  dataStore.getCollection('/projects', function(err, resources) {
    var alreadyExists = resources.some(function(resource) {
      return resource.data.name.toLowerCase() === projectName;
    });

    if (alreadyExists) {
      // The ID already exists, so send an HTTP 409 (Conflict)
      res.sendStatus(409);
    }
    else {
      next();
    }
  });
}
function verifyProjectNameDoesNotExist ( req , res , next ) { var projectName = req . body . name . toLowerCase ( ) ; var dataStore = req . app . dataStore ; // Get all project REST resources dataStore . getCollection ( '/projects' , function ( err , resources ) { var alreadyExists = resources . some ( function ( resource ) { return resource . data . name . toLowerCase ( ) === projectName ; } ) ; if ( alreadyExists ) { // The ID already exists, so send an HTTP 409 (Conflict) res . sendStatus ( 409 ) ; } else { next ( ) ; } } ) ; }
Verifies that the new project's name isn't the same as any existing name.
Verifies that the new project s name isn t the same as any existing name .