Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when use Model.aggregate: Mongoose 5.x disallows passing a spread of operators to Model.aggregate(). Instead of Model.aggregate({ $match }, { $skip }), do Model.aggregate([{ $match }, { $skip }]) #62

Open
wxs77577 opened this issue Aug 9, 2020 · 1 comment

Comments

@wxs77577
Copy link

wxs77577 commented Aug 9, 2020

MongooseError: Mongoose 5.x disallows passing a spread of operators to Model.aggregate(). Instead of Model.aggregate({ $match }, { $skip }), do Model.aggregate([{ $match }, { $skip }])
at Function.aggregate (/Users/johnny/projects/work/tenant-test/node_modules/mongoose/lib/model.js:3921:11)
at Function.aggregate (/Users/johnny/projects/work/tenant-test/node_modules/mongo-tenant/index.js:295:32)
at file:///Users/johnny/projects/work/tenant-test/index.js:31:49
at Layer.handle [as handle_request] (/Users/johnny/projects/work/tenant-test/node_modules/router/lib/layer.js:102:15)
at next (/Users/johnny/projects/work/tenant-test/node_modules/router/lib/route.js:144:13)
at Route.dispatch (/Users/johnny/projects/work/tenant-test/node_modules/router/lib/route.js:109:3)
at handle (/Users/johnny/projects/work/tenant-test/node_modules/router/index.js:515:11)
at Layer.handle [as handle_request] (/Users/johnny/projects/work/tenant-test/node_modules/router/lib/layer.js:102:15)
at /Users/johnny/projects/work/tenant-test/node_modules/router/index.js:291:22
at Function.process_params (/Users/johnny/projects/work/tenant-test/node_modules/router/index.js:349:12)
at next (/Users/johnny/projects/work/tenant-test/node_modules/router/index.js:285:10)
at file:///Users/johnny/projects/work/tenant-test/index.js:22:3
at Layer.handle [as handle_request] (/Users/johnny/projects/work/tenant-test/node_modules/router/lib/layer.js:102:15)
at trim_prefix (/Users/johnny/projects/work/tenant-test/node_modules/router/index.js:330:13)
at /Users/johnny/projects/work/tenant-test/node_modules/router/index.js:294:7
at Function.process_params (/Users/johnny/projects/work/tenant-test/node_modules/router/index.js:349:12)

@redgumnfp
Copy link

As far as I can see, the below (line 295 of index.js):
return super.aggregate.apply(this, operations);

Needs to be:
return super.aggregate.apply(this, [operations]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants