2021-06-10 01:51:59 +02:00
|
|
|
const { Op } = require('sequelize');
|
|
|
|
const Weather = require('../models/Weather');
|
|
|
|
|
|
|
|
const clearWeatherData = async () => {
|
|
|
|
const weather = await Weather.findOne({
|
2021-11-04 23:39:35 +01:00
|
|
|
order: [['createdAt', 'DESC']],
|
2021-06-10 01:51:59 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if (weather) {
|
|
|
|
await Weather.destroy({
|
|
|
|
where: {
|
|
|
|
id: {
|
2021-11-04 23:39:35 +01:00
|
|
|
[Op.lt]: weather.id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2021-06-10 01:51:59 +02:00
|
|
|
}
|
2021-11-04 23:39:35 +01:00
|
|
|
};
|
2021-06-10 01:51:59 +02:00
|
|
|
|
2021-11-04 23:39:35 +01:00
|
|
|
module.exports = clearWeatherData;
|