salix/back/methods/campaign/upcoming.js

30 lines
662 B
JavaScript

module.exports = Self => {
Self.remoteMethod('upcoming', {
description: 'Returns the upcoming campaign',
accessType: 'READ',
accepts: [],
returns: {
type: ['object'],
root: true
},
http: {
path: `/upcoming`,
verb: 'GET'
}
});
Self.upcoming = async() => {
const minDate = Date.vnNew();
minDate.setFullYear(minDate.getFullYear() - 1);
return Self.findOne({
where: {
dated: {
gte: minDate
}
},
order: 'dated ASC'
});
};
};