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/Answer.js

16 lines
635 B
JavaScript

const mongoose = require('mongoose');
const Answer = mongoose.Schema(
{
questionID: { type: mongoose.Schema.Types.ObjectId, ref: 'Question' },
creator: { type: String, required: true, ref: 'User' },
createdAt: { type: Date, required: true },
text: { type: String, required: true },
upvotes: { type: Number, required: true, default: 0 },
downvotes: { type: Number, required: true, default: 0 },
accepted: { type: Boolean, require: true, default: false },
},
{ timestamps: { createdAt: false, updatedAt: true } }
);
module.exports = mongoose.model('Answer', Answer);