lib/models/tags.js
function create(body, cb) {
  var validates = Schema(body);

  if(!validates) {
    return cb(new exceptions.BadRequest());
  }

  body.slug = string.slugify(body.title);

  var q = qb.insert(body);
  db.getClient(function(err, client, done) {
    client.query(q[0], q[1], function(err, r) {
      if(err) {
        if(err.code == 23505) {
          err = new exceptions.AlreadyExists();
        }
        cb(err);
        done(err);
      } else {
        cb(null, r.rows[0]);
        done();
      }
    });
  });
}
function create(body, cb) {
  var validates = Schema(body);

  if(!validates) {
    return cb(new exceptions.BadRequest());
  }

  body.slug = string.slugify(body.title);

  var q = qb.insert(body);
  db.getClient(function(err, client, done) {
    client.query(q[0], q[1], function(err, r) {
      if(err) {
        if(err.code == 23505) {
          err = new exceptions.AlreadyExists();
        }
        cb(err);
        done(err);
      } else {
        cb(null, r.rows[0]);
        done();
      }
    });
  });
}
function create ( body , cb ) { var validates = Schema ( body ) ; if ( ! validates ) { return cb ( new exceptions . BadRequest ( ) ) ; } body . slug = string . slugify ( body . title ) ; var q = qb . insert ( body ) ; db . getClient ( function ( err , client , done ) { client . query ( q [ 0 ] , q [ 1 ] , function ( err , r ) { if ( err ) { if ( err . code == 23505 ) { err = new exceptions . AlreadyExists ( ) ; } cb ( err ) ; done ( err ) ; } else { cb ( null , r . rows [ 0 ] ) ; done ( ) ; } } ) ; } ) ; }
Creates a new tag.

`cb` is passed the newly created tag, or:

* exceptions.BadRequest: if the `body` does not satisfy the schema
* exceptions.AlreadyExists: if a tag with the same slug already exists

@param {Object} body
@param {Function} cb
Creates a new tag .