Limit repeat client side only

I have a query that outputs ‘reading pages’

Within a reading page I have an array of people who are currently reading this page

I want to limit the repeat on the client side, so it’ll only display 10 users opposed to unlimited.

I’d rather not change my query to only output 10 users, as I also want to count the total amount of users.

How can I do this?

There is a .top() formatter to limit the number of records. Just add the number of records as a parameter

2 Likes

I would recommend to use a paged query. That way you can get the total… and just the top records as per limit.

1 Like

Just tested this but doesn’t seem to be compatible with the new subquery system…

  1. I don’t think I can limit a subquery?

  2. If I change this to a custom or query with joins, then how woudl I get the total? Wouldn’t this limit me to X records, regardless of how many records there are?
    I haven’t used paged queries before

This works perfectly, thank you!

I have not used the new subquery thing. So not sure about its limit-ations. :wink:

Total is part of the data returned by all pages queries by default.
You can access it like: sc1.data.pagedquery1.total

Love it! :rofl:

Was expecting this to be the case. Great, then I would have both indeed… I’ll go with Ben’s solution for now and turn it into a paged query when I got more data, as that would be more efficient

1 Like