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

v7.0.0-alpha.1 - MongoInvalidArgumentError: Argument "options" must not be function #729

Open
lien-dkseo opened this issue Apr 5, 2023 · 1 comment

Comments

@lien-dkseo
Copy link

lien-dkseo commented Apr 5, 2023

Steps to reproduce

const cursor = (await this.studyRepository.execute(
  'Study',
  'aggregate',
  [
    {
      $facet: {
        StudyCount: ...,
        SampleTypeCount: ...,
      },
    },
  ],
)) as AggregationCursor;

Current Behavior

MongoInvalidArgumentError: Argument "options" must not be function
    at Collection.aggregate (d:\dev\lien\samplebox-web-backend\node_modules\loopback-connector-mongodb\node_modules\mongodb\lib\collection.js:371:19)
    at d:\dev\lien\samplebox-web-backend\node_modules\loopback-connector-mongodb\lib\mongodb.js:602:38

Expected Behavior

working code in 6.2.0

Link to reproduction sandbox

Additional information

win32 x64 18.15.0

├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── [email protected]
├── [email protected]

Related Issues

See Reporting Issues for more tips on writing good issues

@lien-dkseo lien-dkseo added the bug label Apr 5, 2023
@achrinza achrinza added the v7.x label Apr 10, 2023
@achrinza
Copy link
Member

MongoDB v5 dropped support for the already-deprecated callback-style approach in favour of async/await: mongodb/node-mongodb-native#3499

Offending line is the use of a callback for a Juggler observer:

args[args.length - 1] = observerCallback;
debug('MongoDB: model=%s command=%s', modelName, command, args);
return collection[command].apply(collection, args);

AFAIK, Juggler v4 already supports async/await. Hence this should be a straightforward fix.

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

No branches or pull requests

2 participants