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

Skip/Limit criteria #12

Closed
gamedolphin opened this issue Apr 9, 2022 · 5 comments
Closed

Skip/Limit criteria #12

gamedolphin opened this issue Apr 9, 2022 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@gamedolphin
Copy link

Would be useful to have a skip and limit criteria for number of documents returned by FindAll.

@ostafen
Copy link
Owner

ostafen commented Apr 9, 2022

Thank you for this suggestion. I think that I will add a Limit() method on the Query object :-)

@ostafen ostafen added enhancement New feature or request good first issue Good for newcomers labels Apr 9, 2022
@ostafen
Copy link
Owner

ostafen commented Apr 11, 2022

@gamedolphin, the last commit (5a5de33) adds a Limit(n int) method which allows to limit the output of FindAll() and Count().

You can give a look at the TestLimit function to see an example of usage. Before closing the issue, I wait for your feedback.

@jsgm
Copy link
Contributor

jsgm commented Apr 11, 2022

What do you think about directly returning the document instead an array if Limit(n int) is 1?

@ostafen
Copy link
Owner

ostafen commented Apr 11, 2022

To achieve this, the FindAll() function should return an (interface{}, error). This means you should make additional check and conversion to get the actual type (slice or Document), also making the API not backward compatible.
However your idea is interesting and could be achieved by a separate FindFirst() function, returning a (*Document, error).
We could open a separate issue for this :=)

@ostafen
Copy link
Owner

ostafen commented Apr 12, 2022

@jsgm I added the FindFirst method with the last commit 59c3127
:=)

@ostafen ostafen closed this as completed Apr 12, 2022
@ostafen ostafen added this to the v1.1.0 milestone Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants