renamed backend routes files + add fields to entry model
This commit is contained in:
1 parent
21aaead02a
commit
d6c3a974a1
13 files changed
+24
-18
No files matched your search
@@ -0,0 +1,30 @@
|
||||
const express = require('express');
|
||||
const EntrySeen = require('../models/EntrySeen');
|
||||
const EntryRating = require('../models/EntryRating');
|
||||
const entryRatingsRouter = express.Router();
|
||||
|
||||
// ! /entry-ratings
|
||||
// * PUT - UPDATE ENTRY RATING BY ID
|
||||
entryRatingsRouter.put('/:id', async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const { entryR } = req.body;
|
||||
|
||||
const entryRating = await EntryRating.findByPk(id);
|
||||
if (!entryRating) {
|
||||
return res.status(404).json({ message: 'EntryRating not found' });
|
||||
}
|
||||
|
||||
entryRating.user_rating = entryR.user_rating ?? entryRating.user_rating;
|
||||
entryRating.tmdb_rating = entryR.tmdb_rating ?? entryRating.tmdb_rating;
|
||||
entryRating.imdb_rating = entryR.imdb_rating ?? entryRating.imdb_rating;
|
||||
entryRating.rotten_tomatoes_rating = entryR.rotten_tomatoes_rating ?? entryRating.rotten_tomatoes_rating;
|
||||
|
||||
await entryRating.save();
|
||||
res.status(200).json(entryRating);
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: 'Server error', error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = entryRatingsRouter;
|
||||
Reference in new issue
Block a user