Explorar el Código

replace Tag class

yusuketk hace 7 años
padre
commit
bafd7b7174
Se han modificado 1 ficheros con 26 adiciones y 13 borrados
  1. 26 13
      src/server/models/tag.js

+ 26 - 13
src/server/models/tag.js

@@ -1,16 +1,29 @@
-module.exports = function(crowi) {
-  var debug = require('debug')('growi:models:tag'),
-    mongoose = require('mongoose'),
-    ObjectId = mongoose.Schema.Types.ObjectId,
-    USER_PUBLIC_FIELDS = '_id name',
-    tagSchema;
+const mongoose = require('mongoose');
+const mongoosePaginate = require('mongoose-paginate');
+const ObjectId = mongoose.Schema.Types.ObjectId;
+
+/*
+ * define schema
+ */
+const schema = new mongoose.Schema({
+  name: {
+    type: String,
+    required: true
+  },
+});
+schema.plugin(mongoosePaginate);
 
-  tagSchema = new mongoose.Schema({
-    name: {
-      type: String,
-      required: true
-    },
-  });
+/**
+ * Tag Class
+ *
+ * @class Tag
+ */
+class Tag {
+}
 
-  return mongoose.model('Tag', tagSchema);
+module.exports = function(crowi) {
+  Tag.crowi = crowi;
+  schema.loadClass(Tag);
+  const model = mongoose.model('Tag', schema);
+  return model;
 };