You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
940 B
24 lines
940 B
// comment.js
|
|
// Copyright (C) 2021 Digital Telepresence, LLC
|
|
// License: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
const mongoose = require('mongoose');
|
|
const Schema = mongoose.Schema;
|
|
|
|
const { CommentStats, CommentStatsDefaults } = require(path.join(__dirname, 'lib', 'resource-stats.js'));
|
|
|
|
const CommentSchema = new Schema({
|
|
created: { type: Date, default: Date.now, required: true, index: 1 },
|
|
resourceType: { type: String, enum: ['Post', 'Page', 'Newsletter'], required: true },
|
|
resource: { type: Schema.ObjectId, required: true, index: 1, refPath: 'resourceType' },
|
|
replyTo: { type: Schema.ObjectId, index: 1, ref: 'Comment' },
|
|
author: { type: Schema.ObjectId, required: true, index: 1, ref: 'User' },
|
|
content: { type: String, required: true, maxlength: 3000 },
|
|
stats: { type: CommentStats, default: CommentStatsDefaults, required: true },
|
|
});
|
|
|
|
module.exports = mongoose.model('Comment', CommentSchema);
|