comment.js 832 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 评论表
  5. const CommentSchema = {
  6. newsid: { type: String, required: true, maxLength: 500 }, // 信息ID
  7. uid: { type: String, required: true, maxLength: 500 }, // 用户ID
  8. content: { type: String, required: true }, // 评论内容
  9. public_time: { type: String, required: false, maxLength: 500 }, // 发布时间
  10. status: { type: String, required: false, maxLength: 100, default: '0' }, // 状态,0-未审核,1-审核通过,2-审核拒绝
  11. };
  12. const schema = new Schema(CommentSchema, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Comment', schema, 'comment');
  18. };