Skip to content

Commit

Permalink
BC-5829 - fix migrations changes to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenWaysDP committed Nov 23, 2023
1 parent f6e12e1 commit 15e90e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/feathers-mongoose/error-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/utils/feathers-mongoose/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit 15e90e6

Please sign in to comment.