{"size": 543, "ext": "js", "max_stars_repo_path": "app/models/tech-leader.js", "max_stars_repo_name": "rodrigo103/github-organization-manager", "max_stars_repo_stars_event_min_datetime": "2020-07-25T17:57:07.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-26T10:06:54.000Z", "max_issues_repo_path": "app/models/tech-leader.js", "max_issues_repo_name": "rodrigo103/github-organization-manager", "max_issues_repo_issues_event_min_datetime": "2017-08-22T17:14:00.000Z", "max_issues_repo_issues_event_max_datetime": "2017-08-29T22:58:24.000Z", "max_forks_repo_path": "app/models/tech-leader.js", "max_forks_repo_name": "rodrigo103/github-organization-manager", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 20.8846153846, "max_line_length": 66, "alphanum_fraction": 0.5948434622}
const logger = require('../logger');
const errors = require('../errors');

module.exports = (sequelize, DataTypes) => {
  const TechLeader = sequelize.define(
    'techleader',
    {
      name: { type: DataTypes.STRING, allowNull: false },
      token: DataTypes.STRING
    },
    {
      paranoid: true,
      underscored: true
    }
  );

  TechLeader.getByToken = token => {
    return TechLeader.findOne({ where: { token } }).catch(err => {
      logger.error(err);
      throw errors.databaseError;
    });
  };

  return TechLeader;
};
