{"size": 595, "ext": "js", "max_stars_repo_path": "models/subject.js", "max_stars_repo_name": "idiot-sandwitch/seek", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "models/subject.js", "max_issues_repo_name": "idiot-sandwitch/seek", "max_issues_repo_issues_event_min_datetime": "2021-02-03T16:39:41.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-23T07:47:02.000Z", "max_forks_repo_path": "models/subject.js", "max_forks_repo_name": "idiot-sandwitch/seek", "max_forks_repo_forks_event_min_datetime": "2021-05-18T14:19:40.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-24T18:05:56.000Z"}
{"max_stars_count": null, "max_issues_count": 6, "max_forks_count": 2, "avg_line_length": 19.8333333333, "max_line_length": 57, "alphanum_fraction": 0.6806722689}
const mongoose = require("mongoose");
const Joi = require("joi");
const _ = require("lodash");

const subjectSchema = mongoose.Schema({
  name: {
    type: String,
    required: true,
    unique: true,
  },
});

const Subject = mongoose.model("Subject", subjectSchema);

function validate(subject) {
  const schema = Joi.object({
    name: Joi.string().min(5).max(255).required(),
  });
  return schema.validate(subject);
  }


function pickData(subject) {
  return _.pick(subject, ["name"]);
}

exports.Subject = Subject;
exports.validateSubject = validate;
exports.pickSubjectData = pickData;
