Skip to main content

Method Chaining

  • One method per line should be used if you want to chain methods.
    You should also indent those methods so it's easier to tell they are part of the same chain

    // doUser  .findOne({ name: ‘foo’ })  .populate(‘bar’)  .exec(function(err, user) {    return true;});
    // avoidUser.findOne({ name: 'foo' }).populate('bar').exec(function(err, user) {  return true;});
    // avoidUser.findOne({ name: 'foo' }).populate('bar').exec(function(err, user) {  return true;});