|
@@ -0,0 +1,30 @@
|
|
|
|
+'use strict';
|
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
|
+const moment = require('moment');
|
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
|
+const { ObjectId } = require('mongoose').Types;
|
|
|
|
+// 科技普及表
|
|
|
|
+const universal = {
|
|
|
|
+ type: { type: String }, // 类型
|
|
|
|
+ title: { type: String }, // 标题
|
|
|
|
+ origin: { type: String }, // 来源
|
|
|
|
+ create_time: { type: String }, // 创建时间
|
|
|
|
+ img_url: { type: Array }, // //图片路径
|
|
|
|
+ file_url: { type: Array }, // 文件路径
|
|
|
|
+ content: { type: String }, // 内容
|
|
|
|
+ user_id: { type: ObjectId }, // 创建用户
|
|
|
|
+ remark: { type: String },
|
|
|
|
+};
|
|
|
|
+const schema = new Schema(universal, { toJSON: { virtuals: true } });
|
|
|
|
+schema.index({ id: 1 });
|
|
|
|
+schema.index({ type: 1 });
|
|
|
|
+schema.index({ title: 1 });
|
|
|
|
+schema.index({ create_time: 1 });
|
|
|
|
+schema.index({ user_id: 1 });
|
|
|
|
+schema.index({ origin: 1 });
|
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
|
+schema.plugin(metaPlugin);
|
|
|
|
+module.exports = app => {
|
|
|
|
+ const { mongoose } = app;
|
|
|
|
+ return mongoose.model('Universal', schema, 'universal');
|
|
|
|
+};
|