From a457631a208246fef9aef54b0b60c0a92a4283e1 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Thu, 17 Jun 2021 16:59:14 +0100 Subject: [PATCH] Moved `defaultColumnsToFetch` to Bookshelf CRUD plugin no issue - the CRUD plugin uses this function so we want to keep similar things together to make it easier to test in the future --- core/server/models/base/index.js | 5 ----- core/server/models/base/plugins/crud.js | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/server/models/base/index.js b/core/server/models/base/index.js index 8e3d6dc42b..ec71422b41 100644 --- a/core/server/models/base/index.js +++ b/core/server/models/base/index.js @@ -33,11 +33,6 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({ .filter(key => key.indexOf('@@') === -1); }, - // When loading an instance, subclasses can specify default to fetch - defaultColumnsToFetch: function defaultColumnsToFetch() { - return []; - }, - // Bookshelf `initialize` - declare a constructor-like method for model creation initialize: function initialize() { this.initializeEvents(); diff --git a/core/server/models/base/plugins/crud.js b/core/server/models/base/plugins/crud.js index afe7d9f6bc..60a5b69d3c 100644 --- a/core/server/models/base/plugins/crud.js +++ b/core/server/models/base/plugins/crud.js @@ -210,6 +210,11 @@ module.exports = function (Bookshelf) { // Fetch the object before destroying it, so that the changed data is available to events const obj = await this.forge(options.destroyBy).fetch(options); return obj.destroy(options); + }, + + // When loading an instance, subclasses can specify default to fetch + defaultColumnsToFetch: function defaultColumnsToFetch() { + return []; } }); };