12345678910111213141516171819202122232425 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose/lib/model/schema');
- const { ObjectId } = require('mongoose').Types;
- // 科技新闻表
- const science = {
- title: { type: String, required: false, maxLength: 500 }, // 名称
- publish_time: { type: String, required: false, maxLength: 500 }, // 时间
- origin: { type: String, required: false, maxLength: 500 }, // 来源
- picture: { type: String, required: false }, // 图片
- filepath: { type: String, required: false }, // 附件
- content: { type: String, required: false }, // 正文
- remark: { type: String, maxLength: 200 },
- create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
- };
- const schema = new Schema(science, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Science', schema, 'science');
- };
|