-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Bug: Vue frontend only handles up to 100 entries in pagination #286
Comments
Are you referring to: |
Hardcoding is maybe the wrong wording but the effect is the same since the default limit is 100 users. Well run the test suite a couple of times and you'll have a few hundred users. At this point you'll see that the users view only loads /users with default parameters which is limited to the 100 first in the backend, and does not move the start forward when paginating. Thus making some users unreachable from UI at this point. In my application I've added a /meta route on all collection resources which returns |
I think the default values are some sort of security mechanism, so you don't access all data by accident which might result in very long loading times on the front- and backend. You can always call the api with those values set or even add the logic to query all if to that: async getUsers(token: string, userId: number, skip?: number, limit?: number) {
return axios.get<IUserProfile[]>(`${apiUrl}/api/v1/users/`, {
params: {
...(skip ? {skip: skip} : {}),
...(limit ? {limit: limit} : {}),
},
headers: {
Authorization: `Bearer ${token}`,
},
});
}, And in the backend replace this: with: def get_multi(
self, db: Session, *, skip: int = 0, limit: int = 100
) -> List[ModelType]:
if limit == -1:
return db.query(self.model).offset(skip).all()
return db.query(self.model).offset(skip).limit(limit).all() In theory you should now be able to query all users by calling Anyway, I think this behavior is wanted and in the most cases it is safer to use it with |
I think you misunderstood me. I understand that 100 is the default value and the reasoning behind that, I don't want us to lift that limit. What I'm proposing is simply to allow us to fetch the next 100 from the ui, by going to the next page. In my application I solve the by fetching the next N entries when going to the next page, where N is number of visible entries on the current page. This is a frontend change and doesn't require any changes to the backend, unless we want to be able to get the "max-page" which is more nice to have. |
Ohh 😂 I see. Now, that would be a nice addition I think, do you happen do have already such a code piece? |
I do but we're building the frontend of our project in react so it's
unfortunately not applicable here directly. I could share the meta/count
adaptions on the backend though.
…On Tue, 6 Oct 2020 at 17:37, Maximilian Konter ***@***.***> wrote:
Ohh 😂 I see. Now, that would be a nice addition I think, do you happen
do have already such a code piece?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#286 (comment)>,
|
I've been using fastapi-pagination on a small project to extend endpoints with pagination functionality. On the frontend I'm using |
The vue frontend is hardcoded to 100 items, if you have for instance 400 users it's currently impossible to reach the last ones. The optimal here would be to use a real count but a slightly less optimal but usable solution would be to allow for pagination to continue however long the user want, subsequent pages after the end would simply be empty.
The text was updated successfully, but these errors were encountered: