1
0
Fork 0
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:
unknown 2021-06-10 01:51:59 +02:00
parent 80c807bfba
commit 936da301b8
3 changed files with 27 additions and 3 deletions

22
utils/clearWeatherData.js Normal file
View 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;