mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 03:29:37 +02:00
Clear weather data job. Fixed bug with displaying bookmark icons on mobile devices
This commit is contained in:
parent
80c807bfba
commit
936da301b8
3 changed files with 27 additions and 3 deletions
22
utils/clearWeatherData.js
Normal file
22
utils/clearWeatherData.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { Op } = require('sequelize');
|
||||
const Weather = require('../models/Weather');
|
||||
|
||||
const clearWeatherData = async () => {
|
||||
const weather = await Weather.findOne({
|
||||
order: [[ 'createdAt', 'DESC' ]]
|
||||
});
|
||||
|
||||
if (weather) {
|
||||
await Weather.destroy({
|
||||
where: {
|
||||
id: {
|
||||
[Op.lt]: weather.id
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
console.log('Old weather data was deleted');
|
||||
}
|
||||
|
||||
module.exports = clearWeatherData;
|
Loading…
Add table
Add a link
Reference in a new issue