Merge pull request #2965 from Prat041192/patch-1

Update beforeFetchAll life cycle Bookshelf
This commit is contained in:
Jim LAURIE 2019-03-12 18:12:07 +01:00 committed by GitHub
commit f51596c475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -20,6 +20,14 @@ module.exports = {
// After fetching a value.
// Fired after a `fetch` operation.
// afterFetch: async (model, response, options) => {},
// Before fetching all values.
// Fired before a `fetchAll` operation.
// beforeFetchAll: async (model, columns, options) => {},
// After fetching all values.
// Fired after a `fetchAll` operation.
// afterFetchAll: async (model, response, options) => {},
// Before creating a value.
// Fired before an `insert` query.

View File

@ -236,9 +236,9 @@ module.exports = function(strapi) {
updating: 'beforeUpdate',
updated: 'afterUpdate',
fetching: 'beforeFetch',
'fetching:collection': 'beforeFetchCollection',
'fetching:collection': 'beforeFetchAll',
fetched: 'afterFetch',
'fetched:collection': 'afterFetchCollection',
'fetched:collection': 'afterFetchAll',
saving: 'beforeSave',
saved: 'afterSave'
};
@ -287,9 +287,9 @@ module.exports = function(strapi) {
}
return _.isFunction(
target[model.toLowerCase()]['beforeFetchCollection']
target[model.toLowerCase()]['beforeFetchAll']
)
? target[model.toLowerCase()]['beforeFetchCollection']
? target[model.toLowerCase()]['beforeFetchAll']
: Promise.resolve();
});
@ -314,7 +314,7 @@ module.exports = function(strapi) {
target: 'afterFetch'
}, {
name: 'fetched:collection',
target: 'afterFetchCollection'
target: 'afterFetchAll'
}];
const jsonFormatter = (attributes) => {