This repository has been archived on 2025-11-04. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
qoverflow/server/db/models/Comment.js
2022-07-28 20:50:39 -04:00

21 lines
760 B
JavaScript

const mongoose = require('mongoose');
const Comment = mongoose.Schema(
{
parent_id: { type: mongoose.Schema.Types.ObjectId, refPath: 'docModel' },
comment_id: { type: String, required: true },
creator: { type: String, required: true },
text: { type: String, required: true },
upvotes: { type: Number, required: true, default: 0 },
downvotes: { type: Number, required: true, default: 0 },
createdAt: { type: Date, required: true, default: Date.now },
docModel: {
type: String,
required: true,
enum: ['Question', 'Answer'],
},
},
{ timestamps: { createdAt: false, updatedAt: true } }
);
module.exports = mongoose.model('Comment', Comment);