diff --git a/packages/strapi-generate-api/templates/bookshelf/model.template b/packages/strapi-generate-api/templates/bookshelf/model.template index 6a197959cd..6a75629d9e 100644 --- a/packages/strapi-generate-api/templates/bookshelf/model.template +++ b/packages/strapi-generate-api/templates/bookshelf/model.template @@ -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. diff --git a/packages/strapi-hook-bookshelf/lib/index.js b/packages/strapi-hook-bookshelf/lib/index.js index 2505c0541b..332c03979d 100644 --- a/packages/strapi-hook-bookshelf/lib/index.js +++ b/packages/strapi-hook-bookshelf/lib/index.js @@ -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) => {