const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const timestamps = require('mongoose-timestamp');

const listSchema = new Schema({
  user_id: {
    type: String,
    require: true
  },
  name: {
    type: String,
    require: true
  },
  last_name: {
    type: String,
    require: true
  },
  profession: {
    type: String,
    require: true
  },
  email: {
    type: String,
    require: true,
    default: '',
    match: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
  }
});

listSchema.plugin(timestamps);
const List = mongoose.model('List', listSchema);

module.exports.List = List;
