'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 广告表 const adv = { pos: { type: String }, // 位置:index=>首页;doctor=>医生介绍 image: { type: String }, // 图片 url: { type: String }, // 跳转位置 doctor_id: { type: String }, // 医生id, remark: { type: String, maxLength: 200 }, create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss'), }, }; const schema = new Schema(adv, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ pos: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Adv', schema, 'adv'); };