mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-20 08:41:48 +03:00
21 lines
384 B
JavaScript
21 lines
384 B
JavaScript
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,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = clearWeatherData;
|