Monday, 22 May 2017

How do I return the value of n from this method in Sails.js

getCount: (filter = null) => {
  var whereConditions = {};
  if(filter != null) whereConditions.role = filter;

  User
    .count({
      where: whereConditions,
    })
    .exec((err, n) => {
      console.log(n);
      return n;
    });
}

The method above returns undefined when called, but when I console.log n, I get the correct output. How do I fix this?



via Nicholas Kajoh

No comments:

Post a Comment