Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Object pagination #1048

Closed
0xNacho opened this issue Nov 5, 2015 · 14 comments
Closed

Object pagination #1048

0xNacho opened this issue Nov 5, 2015 · 14 comments

Comments

@0xNacho
Copy link

0xNacho commented Nov 5, 2015

Hi there.

Is there any pagination system implemented when listing entities?

Thanks!

@tmfelwu
Copy link

tmfelwu commented Nov 5, 2015

Yes when admin is viewing all users.

@0xNacho
Copy link
Author

0xNacho commented Nov 5, 2015

Yes, but this pagination is not optimized.
I mean, imagine you have 100.000.00 articles in your MongoDB. By using this pagination, it will request 100.000.000 objects at once.

In my opinion, pagination should load X objects every time you press an index button

@mleanos
Copy link
Member

mleanos commented Nov 5, 2015

@0xNacho You're right. If you need to paginate on a large amount of data, you'll have to take it server-side. You need a route that can fetch the data you want, based on the state of your pagination.

This is a good discussion. I agree with the recommendation that you should have some sort of criteria, like a date filter, other than you're pagination parameters.

http://stackoverflow.com/a/23640287/2228227

@lirantal
Copy link
Member

lirantal commented Nov 7, 2015

Indeed a good topic.
@mleanos I'd say we should look into refactoring our code for server-side pagination too.

@0xNacho
Copy link
Author

0xNacho commented Nov 9, 2015

Cool!

@mleanos
Copy link
Member

mleanos commented Nov 9, 2015

@lirantal Sounds like a good idea. I'll take a look at it, after 0.4.2 is released.

@lirantal
Copy link
Member

lirantal commented Nov 9, 2015

Grea!

On Mon, Nov 9, 2015 at 10:43 AM, Michael Leanos [email protected]
wrote:

@lirantal https://github.com/lirantal Sounds like a good idea. I'll
take a look at it, after 0.4.2 is released.


Reply to this email directly or view it on GitHub
#1048 (comment).

Sincerely, Liran Tal

Author
http://www.amazon.com/Agile-Software-Development-HP-Manager/dp/1484210352/of
Agile Software Development with HP Agile Manager
Founder and Lead Developer of daloRADIUS http://www.daloradius.com/
Blogging at http://www.enginx.com, and tweeting at @liran_tal
https://twitter.com/liran_tal

@0xNacho
Copy link
Author

0xNacho commented Jan 11, 2016

How is it going? some progress with this?

what is the release this feature will be added in?

@tmfelwu
Copy link

tmfelwu commented Jan 11, 2016

You can use the mongoose-paginate plugin for mongoose, its very simple to integrate, I have done the same. Here is a link to it mongoose-paginate

@mleanos
Copy link
Member

mleanos commented Mar 5, 2016

@sparshy The mongoose-paginate looks promising. However, it only works with Node >= 4.2. We're not quite there yet. I'm planning on looking at some alternatives, and if there's a simple implementation without adding any dependencies.

Does anyone have any suggestions?

@mleanos
Copy link
Member

mleanos commented Mar 14, 2016

@0xNacho Have a look at the PR referenced here. WDYT?

If others could also give feedback on this feature, that would be very helpful.

Key considerations with our server-side paging implementation:

  • What we want out of this feature
  • Capabilities
  • Any special considerations as they pertain to the framework
  • Potential pitfalls & possible solutions
  • What aspects of the current PR do we like/don't-like

@0xNacho
Copy link
Author

0xNacho commented Mar 14, 2016

Nice work @mleanos !

Two suggestions:

  • What about indexing createdAt field on articles collection? This should increase read performance.
  • Could we avoid the use of populate in this case? Avoiding joins in MongoDB we drastically increase performance. Since we only need the displayName property, this could be added to the articlescollection (too). In general, data duplication in MongoDB is a good thing in those scenarios where data is not longer maintained/edited (is the property displayName editable?).

@mleanos
Copy link
Member

mleanos commented Mar 14, 2016

@0xNacho Good feedback.

I'll look at adding an index for created.

As for the displayName. Yes, it's editable. Anytime a User updates their profile, the displayName field is set to their firstName & lastName. Avoiding the use of populate() in this case would require a bit of changes, and I'm not even sure there would be a viable alternate solution. It could be that we'd do something funky, like fetching each Article's User info after the list has been resolved; basically when the Article is loaded in the UI. I'm not sure that would be a wise option.

@lirantal lirantal added this to the 0.5.0 milestone Aug 28, 2016
@lirantal
Copy link
Member

Closing issue.

mleanos added a commit to mleanos/mean that referenced this issue Sep 13, 2016
Adds functionality for filtering, sorting, and paging, mongoose queries
on the server-side.

Added error message to list view when server returns error

NOTE: This has been implemented for just the main (public) Articles
list view. We can discuss if we want this on the Admin list as well.

TODO: (Are these necessary for the framework? Or should we let
our users roll their own client-side filtering mechanisms?)
1) Add client-side search input for filtering
2) Create directive for search inputs

Closes meanjs#1048
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants