diff --git a/src/utils/feathers-mongoose/error-handler.js b/src/utils/feathers-mongoose/error-handler.js index 013da28ac88..843fbe6b5ff 100644 --- a/src/utils/feathers-mongoose/error-handler.js +++ b/src/utils/feathers-mongoose/error-handler.js @@ -45,7 +45,7 @@ exports.errorHandler = (error) => { case 'MongoError': return Promise.reject(wrap(new errors.GeneralError(error), error)); default: - return Promise.reject(wrap(new errors.GeneralError(error), error)); + return Promise.reject(wrap(error)); } } diff --git a/src/utils/feathers-mongoose/service.js b/src/utils/feathers-mongoose/service.js index 0a08d17fe02..e6a5ba824ac 100644 --- a/src/utils/feathers-mongoose/service.js +++ b/src/utils/feathers-mongoose/service.js @@ -209,8 +209,9 @@ class Service extends AdapterBase { return model .create(data, params.mongoose) .then((results) => { - if (results === undefined) { - return []; + // https://mongoosejs.com/docs/6.x/docs/migrating_to_6.html#create-with-empty-array + if (Array.isArray(results) && results.length === 0) { + return results; } if ($populate && this.options.whitelist.includes('$populate')) { return Promise.all(results.map((result) => this.Model.populate(result, $populate)));