diff --git a/core/server/data/import/data-importer.js b/core/server/data/import/data-importer.js index e14cc703e9..e1bd8aa4c7 100644 --- a/core/server/data/import/data-importer.js +++ b/core/server/data/import/data-importer.js @@ -23,13 +23,13 @@ DataImporter.prototype.loadRoles = function () { DataImporter.prototype.loadUsers = function () { var users = {all: {}}, - options = _.extend({}, {include: ['roles']}, internal); + options = _.extend({}, {include: ['roles'], limit: 'all'}, internal); - return models.User.findAll(options).then(function (_users) { - _users.forEach(function (user) { - users.all[user.get('email')] = {realId: user.get('id')}; - if (user.related('roles').toJSON(options)[0] && user.related('roles').toJSON(options)[0].name === 'Owner') { - users.owner = user.toJSON(options); + return models.User.findPage(options).then(function (data) { + data.users.forEach(function (user) { + users.all[user.email] = {realId: user.id}; + if (user.roles[0] && user.roles[0].name === 'Owner') { + users.owner = user; } }); diff --git a/core/server/models/index.js b/core/server/models/index.js index 1b7864ca5b..b3aa198470 100644 --- a/core/server/models/index.js +++ b/core/server/models/index.js @@ -44,13 +44,13 @@ models = { deleteAllContent: function deleteAllContent() { var self = this; - return self.Post.findAll().then(function then(posts) { - return Promise.all(_.map(posts.toJSON(), function mapper(post) { + return self.Post.findPage({limit: 'all'}).then(function then(data) { + return Promise.all(_.map(data.posts, function mapper(post) { return self.Post.destroy({id: post.id}); })); }).then(function () { - return self.Tag.findAll().then(function then(tags) { - return Promise.all(_.map(tags.toJSON(), function mapper(tag) { + return self.Tag.findPage({limit: 'all'}).then(function then(data) { + return Promise.all(_.map(data.tags, function mapper(tag) { return self.Tag.destroy({id: tag.id}); })); }); diff --git a/core/server/models/post.js b/core/server/models/post.js index ac89eba606..2250ef7ebe 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -399,7 +399,6 @@ Post = ghostBookshelf.Model.extend({ // whitelists for the `options` hash argument on methods, by method name. // these are the only options that can be passed to Bookshelf / Knex. validOptions = { - findAll: ['withRelated'], findOne: ['importing', 'withRelated'], findPage: ['page', 'limit', 'columns', 'status', 'staticPages', 'featured'], add: ['importing'] @@ -431,20 +430,6 @@ Post = ghostBookshelf.Model.extend({ // ## Model Data Functions - /** - * ### Find All - * - * @param {Object} options - * @returns {*} - */ - findAll: function findAll(options) { - options = options || {}; - - // fetch relations passed to options.include - options.withRelated = _.union(options.withRelated, options.include); - return ghostBookshelf.Model.findAll.call(this, options); - }, - /** * ### Find One * @extends ghostBookshelf.Model.findOne to handle post status diff --git a/core/server/models/user.js b/core/server/models/user.js index 83542e2d96..9ef496a6f2 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -228,7 +228,6 @@ User = ghostBookshelf.Model.extend({ // these are the only options that can be passed to Bookshelf / Knex. validOptions = { findOne: ['withRelated', 'status'], - findAll: ['withRelated'], setup: ['id'], edit: ['withRelated', 'id'], findPage: ['page', 'limit', 'columns', 'status'] @@ -241,18 +240,6 @@ User = ghostBookshelf.Model.extend({ return options; }, - /** - * ### Find All - * - * @param {Object} options - * @returns {*} - */ - findAll: function findAll(options) { - options = options || {}; - options.withRelated = _.union(options.withRelated, options.include); - return ghostBookshelf.Model.findAll.call(this, options); - }, - /** * ### Find One * @extends ghostBookshelf.Model.findOne to include roles