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

Can't do pagination #85

Open
yogiGueta opened this issue Aug 25, 2020 · 7 comments
Open

Can't do pagination #85

yogiGueta opened this issue Aug 25, 2020 · 7 comments

Comments

@yogiGueta
Copy link

Hi,
I am trying to do some pagination without a success. I read a lot of posts, but I can't find a concrete answer.
My scenario is very simple:
I have AD with 2000 users, I want use findUsers() function and get only 200 users at a time,
so I configured:
General AD config:
activeDirectoryConfig.paged = true;
Opt config:
opts.paging = {
pageSize: 200,
};

Now I am getting the first 200 users (1-200), but how can I get the next 200 users (201-400)? What is the correct way to tell findUsers() to give me the next page (to start the fetching from offset 201 and not 0)?
Thanks,
BTW I am using [email protected].

@jsumners
Copy link
Owner

🤷‍♂️

I can't remember, but I don't think the findUsers method supports pagination. You might need to use the generic find method. You'll need to look through the source code to make a determination.

@yogiGueta
Copy link
Author

@jsumners Can you please explain (or give some example) how can I achieve it using the find method?

@jsumners
Copy link
Owner

I do not have access to an AD server. Please see the notice I added to the readme.

@jurjendijkstra
Copy link

Just out of curiosity, why do you want to go to the trouble to define a small pagesize and manage the paging yourself, if findUsers() has paging built-in and can return all your 2000 users at once (by automatically fetching and joining all necessary pages for you)?

If I recall correctly, you don't specify that you want results from offset 201. Instead the query returns some object and you must pass that exact object to the next call, which returns an object again which you pass to the next call, repeat that until it is done.

@yogiGueta
Copy link
Author

Let's say I have an unknown number of users (over 500k), and I have an application with UI. The UI can display only 200 users at a time (in a page).
The scenario is: the user enter to the UI page, I don't want him to wait until AD findUsers will process and bring me back all of my 500k users. I just want it to return quickly the first 200 users that can be display in the page (and match the search query). There is a lot of chances that the user will find what he want between them, if not, he should press on the next page button, and only then I will bring him the next 200 users.
Is this more clear?
@jurjendijkstra I need a way to control the pages return from AD. I need to get the first page, and if it's not good, to get the second one etc.

@jurjendijkstra
Copy link

@yogiGueta I understand, I am using the activedirectory in a different scenario, thanks for the insight. And 500K is a serious number, for just 2000 I might still fetch them all at once and do a paged UI.
I don't know how to control the paging. It looks like it is done under the hood by the ldapjs module.

It is none of my business but perhaps you can consider a UI design where the user is informed that there were more than {pagesize} hits for his initial query, then enable him to refine the query until there are less than {pagesize} hits....

@jsumners
Copy link
Owner

You may need to use ldapjs directly.

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

3 participants