{"size": 623, "ext": "js", "max_stars_repo_path": "server/schemas/Locations.js", "max_stars_repo_name": "treemmett/netlist", "max_stars_repo_stars_event_min_datetime": "2018-06-25T16:39:06.000Z", "max_stars_repo_stars_event_max_datetime": "2018-06-25T16:39:06.000Z", "max_issues_repo_path": "server/schemas/Locations.js", "max_issues_repo_name": "treemmett/netlist", "max_issues_repo_issues_event_min_datetime": "2018-06-25T16:23:09.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-08T22:08:21.000Z", "max_forks_repo_path": "server/schemas/Locations.js", "max_forks_repo_name": "treemmett/netlist", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 8, "max_forks_count": null, "avg_line_length": 21.4827586207, "max_line_length": 70, "alphanum_fraction": 0.606741573}
const mongoose = require('mongoose');

const schema = mongoose.Schema({
  code: {
    type: String,
    trim: true,
    minlength: 3,
    maxlength: 3,
    required: true,
    uppercase: true,
    unique: true,
    validate: {
      validator: function(v){
        return /^[a-zA-Z]{3}$/.test(v);
      },
      message: 'Only A-Z characters are allowed for prefix'
    }
  },
  description: {
    type: String,
    trim: true,
    required: true
  }
});
schema.pre('findOneAndUpdate', function(next){
  this.options.runValidators = true;
  next();
});
const Location = module.exports = mongoose.model('Locations', schema);