12345678910111213141516171819202122232425262728 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 文章表
- const article = {
- title: { type: String }, // 标题
- user: { type: String }, // 医生
- user_id: { type: String }, // 医生id
- origin: { type: String }, // 来源
- img_url: { type: String }, // 图片
- brief: { type: String }, // 简介
- content: { type: String }, // 内容
- file_url: { type: String }, // 附件
- remark: { type: String, maxLength: 200 },
- create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
- };
- const schema = new Schema(article, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ title: 1 });
- schema.index({ user: 1 });
- schema.index({ user_id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Article', schema, 'article');
- };
|