upload files

This commit is contained in:
sbinsalman
2025-11-25 11:11:42 -07:00
commit 36f9a5e69b
41 changed files with 1971 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import mongoose, { model } from "mongoose";
const { Schema } = mongoose;
const CommentUserStorySchema = new Schema(
{
userStoryId: { type: Schema.Types.ObjectId, ref: "UserStory", required: true },
commentText: { type: String, required: true },
commentedBy: { type: String, required: true },
},
{ timestamps: true }
);
CommentUserStorySchema.post("save", async function (doc, next) {
try {
await mongoose.model("UserStory").findByIdAndUpdate(
doc.userStoryId,
{ $addToSet: { comments: doc._id } } // $addToSet avoids duplicates
);
next();
} catch (err) {
next(err);
}
});
export default model("Comment", CommentUserStorySchema);

View File

@@ -0,0 +1,20 @@
import mongoose, { model } from "mongoose";
const { Schema } = mongoose;
const UserStorySchema = new Schema(
{
title: { type: String, required: true },
description: { type: String, required: true },
status: { type: String, enum: ["Todo", "In-Review", "Sprint-Ready"], default: "Todo" },
businessValue: { type: Number, required: true, min: 1, max: 100 },
storyPoint: { type: Number, required: true, enum: [1, 2, 3, 5, 8, 13, 21, 34, 55] },
assignedTo: { type: String },
comments: [{ type: Schema.Types.ObjectId, ref: "Comment" }],
},
{ timestamps: true }
);
//Sorting by most recent
UserStorySchema.index({ createdAt: -1 });
export default model("UserStory", UserStorySchema);