share-link.js 664 B

1234567891011121314151617181920212223242526272829
  1. // disable no-return-await for model functions
  2. /* eslint-disable no-return-await */
  3. const mongoose = require('mongoose');
  4. const uniqueValidator = require('mongoose-unique-validator');
  5. const ObjectId = mongoose.Schema.Types.ObjectId;
  6. /*
  7. * define schema
  8. */
  9. const schema = new mongoose.Schema({
  10. relatedPage: {
  11. type: ObjectId,
  12. ref: 'Page',
  13. required: true,
  14. index: true,
  15. },
  16. expiredAt: { type: Date },
  17. description: { type: String },
  18. createdAt: { type: Date, default: Date.now, required: true },
  19. });
  20. schema.plugin(uniqueValidator);
  21. module.exports = function(crowi) {
  22. const model = mongoose.model('ShareLink', schema);
  23. return model;
  24. };