Yuki Takei 8 лет назад
Родитель
Сommit
3246df0b18
2 измененных файлов с 32 добавлено и 0 удалено
  1. 31 0
      lib/models/external-account.js
  2. 1 0
      lib/models/index.js

+ 31 - 0
lib/models/external-account.js

@@ -0,0 +1,31 @@
+const debug = require('debug')('crowi.models.external-account');
+const mongoose = require('mongoose');
+const uniqueValidator = require('mongoose-unique-validator');
+const ObjectId = mongoose.Schema.Types.ObjectId;
+
+/*
+ * define schema
+ */
+const schema = new mongoose.Schema({
+  providerType: { type: String, required: true },
+  accountId: { type: String, required: true },
+  user: { type: ObjectId, ref: 'User', required: true },
+  createdAt: { type: Date, default: Date.now, required: true },
+});
+// compound index
+schema.index({ providerType: 1, accountId: 1 });
+// apply plugins
+schema.plugin(uniqueValidator);
+
+/**
+ * ExternalAccount Class
+ *
+ * @class ExternalAccount
+ */
+class ExternalAccount {
+}
+
+module.exports = function(crowi) {
+  schema.loadClass(ExternalAccount);
+  return mongoose.model('ExternalAccount', schema);
+}

+ 1 - 0
lib/models/index.js

@@ -3,6 +3,7 @@
 module.exports = {
   Page: require('./page'),
   User: require('./user'),
+  ExternalAccount: require('./external-account'),
   Revision: require('./revision'),
   Bookmark: require('./bookmark'),
   Comment: require('./comment'),