Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Support passing options to .find() #39

Open
ericrallen opened this issue Apr 3, 2019 · 2 comments · May be fixed by #40
Open

Support passing options to .find() #39

ericrallen opened this issue Apr 3, 2019 · 2 comments · May be fixed by #40

Comments

@ericrallen
Copy link

It doesn't seem to be possible to use sort or limit with botkit-storage-mongo because the exposed API does not accept options and pass them through to monk.

This means you can only ever retrieve all of the items in a collection that meet your query parameters and they will be returned in an order determined by Mongo.

This is less than ideal for many usecases.

I plan to submit a PR to address this, but am not sure whether you'd rather the exposed API become polymorphic and allow the options to be an optional second parameter, which I think the monk API supports, or if you'd prefer we break the convention of the monk API and add the options as an argument after the callback. Either of these options should be backwards compatible and not break any existing code that uses botkit-storage-mongo.

@ericrallen
Copy link
Author

Here is the relevant documentation from monk: https://automattic.github.io/monk/docs/collection/find.html

@ericrallen
Copy link
Author

Here's a StackOverflow answer showing it in practice: https://stackoverflow.com/a/19955252/656011

And here's the relevant code from monk. It appears they use a polymorphic signature where the options arguments is optional. I'm working on a PR now that mirrors their approach.

@ericrallen ericrallen linked a pull request Apr 9, 2019 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant