Skip to content

Commit

Permalink
issue api
Browse files Browse the repository at this point in the history
  • Loading branch information
malik-na committed Sep 22, 2024
1 parent 2b87f83 commit 235a3de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion backend/src/controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export const userController = {

getUsers: async (req, res) => {
try {
const users = await User.find();
const users = await User.find().populate(
"assignedIssues",
"title status"
);
res.json(users);
} catch (error) {
res.status(500).json({ error: error.message });
Expand Down
10 changes: 7 additions & 3 deletions backend/src/models/Issue.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mongoose from "mongoose";
const issueSchema = new mongoose.Schema(
{
title: { type: String, required: true },
description: { type: String, required: true },
description: { type: String, required: false },
status: {
type: String,
enum: ["OPEN", "IN_PROGRESS", "CLOSED"],
Expand All @@ -12,9 +12,13 @@ const issueSchema = new mongoose.Schema(
assignedTo: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
required: false,
},
team: {
type: mongoose.Schema.Types.ObjectId,
ref: "Team",
required: false,
},
team: { type: mongoose.Schema.Types.ObjectId, ref: "Team", required: true },
},
{ timestamps: true }
);
Expand Down
6 changes: 6 additions & 0 deletions backend/src/models/User.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const userSchema = new mongoose.Schema(
ref: "Team",
required: false,
},
assignedIssues: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Issue",
},
],
projects: [
{
type: mongoose.Schema.Types.ObjectId,
Expand Down

0 comments on commit 235a3de

Please sign in to comment.