comment.js 704 B

123456789101112131415161718192021
  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. };
  11. const schema = new Schema(CommentSchema, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Comment', schema, 'live_comment');
  17. };