Skip to content

Commit

Permalink
feat(apis): add cron list request to services ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Apr 22, 2020
1 parent 1cc6901 commit bae1c75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/apis/repositories/apis.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const defaultPopulate = [{
*/
exports.list = (user) => Api.find({ user: user._id }).select('-history').sort('-createdAt').exec();

/**
* @desc Function to get all scrap to cron in db
* @return {Array} All scraps
*/
exports.cron = () => Api.find({ cron: { $ne: null, $exists: true } }).populate('containers')
.exec();


/**
* @desc Function to create a api in db
* @param {Object} api
Expand Down
10 changes: 10 additions & 0 deletions modules/apis/services/apis.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ exports.list = async (user) => {
return Promise.resolve(result);
};

/**
* @desc Function to get all scrap to cron in db
* @return {Promise} All scraps
*/
exports.cron = async () => {
const result = await ApisRepository.cron();
return Promise.resolve(result);
};


/**
* @desc Function to ask repository to create a api
* @param {Object} api
Expand Down

0 comments on commit bae1c75

Please sign in to comment.