|
@@ -0,0 +1,27 @@
|
|
|
+'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 topic = {
|
|
|
+ user_id: { type: ObjectId },
|
|
|
+ content: { type: String }, // 内容
|
|
|
+ origin: { type: String }, // 来源
|
|
|
+ renew_time: { type: String }, // 更新时间
|
|
|
+ type: { type: String }, // 类型:0=>图文;1=>视频
|
|
|
+ imgUrl: { type: Array }, // 图片
|
|
|
+ fileUrl: { type: Array }, // 视频
|
|
|
+ website: { type: String }, // 网址
|
|
|
+ read: { type: Number, default: 0 }, // 阅读数
|
|
|
+ remark: { type: String, maxLength: 200 },
|
|
|
+ create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
|
|
|
+};
|
|
|
+const schema = new Schema(topic, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Topic', schema, 'topic');
|
|
|
+};
|