Browse Source

Merge branch 'support/share-link-for-outside-for-merge' into feat/create-apiv3-delete-share-link

itizawa 5 năm trước cách đây
mục cha
commit
1d31820e13
2 tập tin đã thay đổi với 32 bổ sung0 xóa
  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;
+};