Advertisement
Guest User

Untitled

a guest
May 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const mongoose = require('mongoose');
  2. const Schema = mongoose.Schema;
  3.  
  4. const CategoryScheme = new Schema({
  5.   name: {
  6.     type: String,
  7.     default: '',
  8.     required: true,
  9.   },
  10.   slug: {
  11.     type: String,
  12.     default: '',
  13.     required: true,
  14.     unique: true,
  15.   },
  16. });
  17.  
  18. const Category = mongoose.model('category', CategoryScheme);
  19.  
  20. module.exports.Category = Category;
  21. module.exports.Schema = CategoryScheme;
  22.  
  23. const mongoose = require('mongoose');
  24. const Schema = mongoose.Schema;
  25.  
  26. const TagScheme = new Schema({
  27.   name: {
  28.     type: String,
  29.     default: '',
  30.     required: true,
  31.   },
  32.   slug: {
  33.     type: String,
  34.     default: '',
  35.     required: true,
  36.     unique: true,
  37.   },
  38. });
  39.  
  40. const Tag = mongoose.model('tag', TagScheme);
  41.  
  42. module.exports.Tag = Tag;
  43. module.exports.Schema = TagScheme;
  44.  
  45.  
  46. const mongoose = require('mongoose');
  47. const Schema = mongoose.Schema;
  48.  
  49. const JobSchema = new Schema({
  50.   title: {
  51.     type: String,
  52.     default: '',
  53.     required: true,
  54.   },
  55.  
  56.   description: {
  57.     type: String,
  58.     default: '',
  59.     required: true,
  60.   },
  61.  
  62.   tags: {
  63.     type: Schema.ObjectId,
  64.     ref: 'tag',
  65.     required: true,
  66.     default: [],
  67.   },
  68.  
  69.   category: {
  70.     type: Schema.ObjectId,
  71.     ref: 'category',
  72.     required: true,
  73.   },
  74.  
  75.   experienceLevel: {
  76.     type: String,
  77.     required: true,
  78.     enum: ['Entry level', 'Intermediate', 'Expert']
  79.   },
  80.  
  81.   createdAt: {
  82.     type: Date,
  83.     default: Date.now
  84.   },
  85.   updateAt: {
  86.     type: Date,
  87.     default: Date.now
  88.   }
  89. });
  90.  
  91. const Job = mongoose.model('job', JobSchema);
  92.  
  93. module.exports.Job = Job;
  94. module.exports.Schema = JobSchema;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement