{"size": 941, "ext": "js", "max_stars_repo_path": "dao/productsDAO.js", "max_stars_repo_name": "RafaelGoulartB/nodejs-shopping-cart", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dao/productsDAO.js", "max_issues_repo_name": "RafaelGoulartB/nodejs-shopping-cart", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dao/productsDAO.js", "max_forks_repo_name": "RafaelGoulartB/nodejs-shopping-cart", "max_forks_repo_forks_event_min_datetime": "2020-09-18T12:37:26.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-18T12:37:26.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 26.1388888889, "max_line_length": 76, "alphanum_fraction": 0.5026567481}
class productsDAO {
  constructor(connection) {
    this.connection = connection;
  }

  list(limmit) {
    return new Promise((resolve, reject) => {
      if (!limmit) {
        this.connection.query('select * from products', (error, result) => {
          if (error) return reject(error);
          return resolve(result);
        });
      }
      this.connection
          .query('select * from products limit ?', limmit,
              (err, result) => {
                if (err) return reject(err);
                return resolve(result);
              });
    }); // End Promise
  }; // End list

  getByIds(ids) {
    return new Promise((resolve, reject) => {
      this.connection
          .query(`SELECT * FROM products WHERE id in (${ids})`,
              (err, result) => {
                if (err) return reject(err);
                return resolve(result);
              });
    });
  };
}

module.exports = () => productsDAO;
