upd
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user