add: update modal for entry seen
This commit is contained in:
1 parent
d6c3a974a1
commit
bffc1227c3
8 files changed
+208
-81
No files matched your search
@@ -65,13 +65,15 @@ entryRouter.get('/:id', async (req, res) => {
|
||||
attributes: [] // Do not fetch any attributes from the join table
|
||||
}
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||
]
|
||||
});
|
||||
if (!entry) { // ! entry not found
|
||||
res.status(404).json({ message: 'Entry not found' });
|
||||
}
|
||||
|
||||
|
||||
const entryData = entry.get({ plain: true });
|
||||
const genres = entryData.genres.map(genre => genre.name);
|
||||
|
||||
@@ -172,7 +174,10 @@ entryRouter.put('/:id', async (req, res) => {
|
||||
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||
|
||||
const updatedEntry = await Entry.findByPk(id, {
|
||||
include: includes
|
||||
include: includes,
|
||||
order: [
|
||||
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||
]
|
||||
});
|
||||
|
||||
const entryData = updatedEntry.get({ plain: true });
|
||||
|
||||
+3
-3
@@ -63,12 +63,12 @@ app.use(errorHandler);
|
||||
app.use('/killer', killerRouter);
|
||||
|
||||
// Start the server
|
||||
|
||||
const doUpdate = false;
|
||||
console.log(`Syncing database schema...`);
|
||||
sequelize
|
||||
// .sync({force: true}) // will drop all tables and recreate them.
|
||||
// .sync({ alter: true }) // will attempt to automatically alter tables to fit the model definitions.
|
||||
.sync()
|
||||
.sync({ alter: doUpdate }) // will attempt to automatically alter tables to fit the model definitions.
|
||||
// .sync()
|
||||
.then((result) => {
|
||||
console.log(`Database schema synced...`);
|
||||
initializeData();
|
||||
|
||||
@@ -515,7 +515,10 @@ async function refrechEntry(entryId) {
|
||||
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||
|
||||
const updatedEntry = await Entry.findByPk(entryId, {
|
||||
include: includes
|
||||
include: includes,
|
||||
order: [
|
||||
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||
]
|
||||
});
|
||||
|
||||
const entryData = updatedEntry.get({ plain: true });
|
||||
|
||||
Reference in new issue
Block a user