adv.js 811 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. // 广告表
  6. const adv = {
  7. pos: { type: String }, // 位置:index=>首页;doctor=>医生介绍
  8. image: { type: String }, // 图片
  9. url: { type: String }, // 跳转位置
  10. doctor_id: { type: String }, // 医生id,
  11. remark: { type: String, maxLength: 200 },
  12. create_time: {
  13. type: String,
  14. default: moment().format('YYYY-MM-DD HH:mm:ss'),
  15. },
  16. };
  17. const schema = new Schema(adv, { toJSON: { virtuals: true } });
  18. schema.index({ id: 1 });
  19. schema.index({ pos: 1 });
  20. schema.index({ 'meta.createdAt': 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('Adv', schema, 'adv');
  25. };