Skip to content

Promise consistency #74

@besarthoxhaj

Description

@besarthoxhaj

Hi all!:)

Really like the db helpers, that's a nice way to decouple functionality and provide just an high level function to be used around the code while hiding implementation.

Noticed however that you use a callback pattern in some places and promises in others. In case you don't know how to create a promise pattern here is an example:

// normal callback pattern
function getItem (id,callback) {

  // some async call to db
  if (err) {
    callback(err,null);
  } else {
    callback(null,{id:5,name:'Bes'});
  }
}
// normal promise pattern
const Promise = require('bluebird');

function getItem (id) {

  return new Promise(function (resolve, reject) {
    // some async call to db
    if (err) {
      reject(err);
    } else {
      resolve({id:5,name:'Bes'});
    }
  });
}

Hope that helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions