reply.js 945 B

12345678910111213141516171819202122232425262728
  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. const { ObjectId } = require('mongoose').Types;
  6. // 回复表
  7. const reply = {
  8. name: { type: String },
  9. icon: { type: String },
  10. openid: { type: String },
  11. content: { type: String },
  12. reply_time: { type: String },
  13. article_id: { type: ObjectId },
  14. remark: { type: String, maxLength: 200 },
  15. create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
  16. };
  17. const schema = new Schema(reply, { toJSON: { virtuals: true } });
  18. schema.index({ id: 1 });
  19. schema.index({ name: 1 });
  20. schema.index({ openid: 1 });
  21. schema.index({ reply_time: 1 });
  22. schema.index({ article_id: 1 });
  23. schema.index({ 'meta.createdAt': 1 });
  24. schema.plugin(metaPlugin);
  25. module.exports = app => {
  26. const { mongoose } = app;
  27. return mongoose.model('Reply', schema, 'reply');
  28. };