12345678910111213141516171819202122232425262728293031 |
- '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 open_info = {
- user_id: { type: ObjectId },
- column_name: { type: String }, // 栏目名称
- title: { type: String }, // 标题
- release_time: { type: String }, // 发布时间
- origin: { type: String }, // 来源
- content: { type: String }, // 内容
- image: { type: Array }, // 图片
- fileUrl: { type: Array }, // 附件
- remark: { type: String },
- create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
- };
- const schema = new Schema(open_info, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ user_id: 1 });
- schema.index({ column_name: 1 });
- schema.index({ origin: 1 });
- schema.index({ title: 1 });
- schema.index({ release_time: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Open_info', schema, 'open_info');
- };
|