This commit is contained in:
2024-06-12 20:06:30 +05:00
parent e155066534
commit a46547d1fe
19 changed files with 634 additions and 513 deletions
+23
View File
@@ -0,0 +1,23 @@
import { model, Schema } from "mongoose";
const rolesSchema = new Schema(
{
userId: {
type: Schema.Types.ObjectId,
required: true,
},
name: {
type: String,
required: true,
},
},
{
timestamps: true,
toJSON: { virtuals: true },
toObject: { virtuals: true },
}
);
const Roles = model("Roles", rolesSchema);
export default Roles;
+14 -1
View File
@@ -142,7 +142,20 @@ router.put("/:id/scheduled_sessions/:scheduledSessionId", async (req, res) => {
userId: req.body.userId,
});
if (scheduledSessionAtSameTime) {
if (scheduledSessionAtSameTime && req.body.userId !== null) {
await ScheduledSession.updateMany(
{
userId: req.body.userId,
startAt: scheduledSession?.startAt,
},
{
userId: null,
}
);
await ScheduledSession.findByIdAndUpdate(req.params.scheduledSessionId, {
userId: req.body.userId,
});
res.json({ error: "Scheduled session at same time" });
return;
}
+3 -1
View File
@@ -1,7 +1,7 @@
import { Router } from "express";
// import User from "../models/User.js";
const usersRouter = Router();
const router = Router();
// usersRouter.get("/", async (_req, res) => {
// const users = await User.find();
@@ -17,4 +17,6 @@ const usersRouter = Router();
// res.json(user);
// });
const usersRouter = router;
export default usersRouter;