Просмотр исходного кода

Merge pull request #2328 from weseek/feat/create-share-link-collection

feat/create-share-link-collection
Yuki Takei 5 лет назад
Родитель
Сommit
b830f6c46b
2 измененных файлов с 32 добавлено и 0 удалено
  1. 1 0
      src/server/models/index.js
  2. 31 0
      src/server/models/share-link.js

+ 1 - 0
src/server/models/index.js

@@ -15,4 +15,5 @@ module.exports = {
   GlobalNotificationSetting: require('./GlobalNotificationSetting'),
   GlobalNotificationMailSetting: require('./GlobalNotificationSetting/GlobalNotificationMailSetting'),
   GlobalNotificationSlackSetting: require('./GlobalNotificationSetting/GlobalNotificationSlackSetting'),
+  ShareLink: require('./share-link'),
 };

+ 31 - 0
src/server/models/share-link.js

@@ -0,0 +1,31 @@
+// disable no-return-await for model functions
+/* eslint-disable no-return-await */
+
+const mongoose = require('mongoose');
+const uniqueValidator = require('mongoose-unique-validator');
+
+const ObjectId = mongoose.Schema.Types.ObjectId;
+
+/*
+ * define schema
+ */
+const schema = new mongoose.Schema({
+  relatedPage: {
+    type: ObjectId,
+    ref: 'Page',
+    required: true,
+    index: true,
+  },
+  expiration: { type: Date },
+  description: {
+    type: String,
+  },
+  createdAt: { type: Date, default: Date.now, required: true },
+});
+
+schema.plugin(uniqueValidator);
+
+module.exports = function(crowi) {
+  const model = mongoose.model('ShareLink', schema);
+  return model;
+};