Issue #12 resolved

Limit not working

kisyad avatarkisyad created an issue

Hi,

Currently only {limit, 1} seems to be working.

Test case

emongo:insert(pool1, "testlimit", {id, 1}).
emongo:insert(pool1, "testlimit", {id, 2}).
emongo:insert(pool1, "testlimit", {id, 3}).
length(emongo:find_all(pool1, "testlimit", [], [ {limit, 2} ] )).  

-> result 3

I did a quick look and everything seems to go fine up to emongo:fold_all_seq.

NewValue = fold_documents(F, Value, Resp), seems to return two documents as expected but then fold_more is called which ignores the limit and returns all 3 documents.

Comments (2)

  1. Dmitry Belyaev
    • changed status to open

    The problem is that on first call of query mongodb returns required set of documents in one response (e.g. 1000 documents in one response) and leaves cursor alive and ready for further fetching beyond desired limit. And fold_more assumes that mongodb will tell when the query is over with cursor value of 0.

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.