123456789101112131415161718192021 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 评论表
- const CommentSchema = {
- newsid: { type: String, required: true, maxLength: 500 }, // 信息ID
- uid: { type: String, required: true, maxLength: 500 }, // 用户ID
- content: { type: String, required: true }, // 评论内容
- public_time: { type: String, required: false, maxLength: 500 }, // 发布时间
- };
- const schema = new Schema(CommentSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Comment', schema, 'live_comment');
- };
|