mirror of
https://github.com/pawelmalak/flame.git
synced 2026-03-11 06:53:12 +08:00
Clear weather data job. Fixed bug with displaying bookmark icons on mobile devices
This commit is contained in:
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;
|
||||
Reference in New Issue
Block a user