salix/back/methods/campaign/upcoming.js

30 lines
660 B
JavaScript
Raw Normal View History

2020-10-05 05:53:03 +00:00
module.exports = Self => {
Self.remoteMethod('upcoming', {
description: 'Returns the lastest campaigns',
accessType: 'READ',
accepts: [],
returns: {
type: ['object'],
root: true
},
http: {
path: `/upcoming`,
verb: 'GET'
}
});
Self.upcoming = async() => {
const minDate = new Date();
2020-10-05 12:45:39 +00:00
minDate.setFullYear(minDate.getFullYear() - 1);
2020-10-05 05:53:03 +00:00
return Self.findOne({
where: {
dated: {
2020-10-05 12:45:39 +00:00
gte: minDate
2020-10-05 05:53:03 +00:00
}
},
2020-10-05 12:45:39 +00:00
order: 'dated ASC'
2020-10-05 05:53:03 +00:00
});
};
};