-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from nishant0708/feedback
Feat:Want to Write Backend Of FeedBack Page Of Canteens #421
- Loading branch information
Showing
6 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const asyncHandler = require('express-async-handler'); | ||
const Feedback = require("../models/studentfeeback"); | ||
|
||
const submitFeedback = asyncHandler(async (req, res) => { | ||
const { message, canteenId ,userId} = req.body; | ||
|
||
|
||
if (!message || !canteenId) { | ||
res.status(400); | ||
throw new Error('Message and Canteen ID are required'); | ||
} | ||
|
||
const feedback = new Feedback({ message, canteenId, userId }); | ||
await feedback.save(); | ||
res.status(201).json({ message: 'Feedback submitted successfully' }); | ||
}); | ||
|
||
module.exports = { submitFeedback }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const mongoose = require('mongoose'); | ||
const Schema = mongoose.Schema; | ||
|
||
const studentfeedbackSchema = new Schema({ | ||
message: { type: String, required: true }, | ||
canteenId: { type: mongoose.Schema.Types.ObjectId, ref: 'Canteen', required: true }, | ||
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true }, | ||
createdAt: { type: Date, default: Date.now } | ||
}); | ||
|
||
module.exports = mongoose.model('StudentFeedback', studentfeedbackSchema ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters