salix/back/methods/campaign/upcoming.js

31 lines
661 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();
minDate.setMonth(0);
minDate.setDate(1);
return Self.findOne({
where: {
dated: {
lt: minDate
}
},
order: 'dated DESC'
});
};
};