{"size": 487, "ext": "js", "max_stars_repo_path": "src/api/services/crimeTypeService.js", "max_stars_repo_name": "Crimern/backend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/api/services/crimeTypeService.js", "max_issues_repo_name": "Crimern/backend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/api/services/crimeTypeService.js", "max_forks_repo_name": "Crimern/backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 16.2333333333, "max_line_length": 47, "alphanum_fraction": 0.4579055441}
export default (database) => {

  const { Crime, CrimeType } = database.models;

  return {
    async create({ name }) {
      try {
        const data = new CrimeType({
          name: name
        })

        await data.save();        
        return data;

      } catch (error) {
        throw error;
      }
    },

    async fetchAll() {
      try {
        const data = await CrimeType.find({})

        return data;
      } catch(error) {
        throw error;
      }
    }
  }
}