
I want to get the searched result in pagination but i am not getting that so is it possible to paginate search results
TL;DR
Developers want to implement infinite scroll pagination with React Query using Query.Search. The issue seems to be with fetching the search results in pagination. The code provided shows the use of `useInfiniteQuery` and `authservice.getInfiniteUserResult` to fetch the data. The solution may involve debugging the `useGetInfinityUserSearch` and `getInfiniteUserResult` functions to ensure proper handling of pagination.
TypeScript
getInfiniteUserResult=async({pageParam,id}: { pageParam: number, id:string })=>{
const queries: any[] = [Query.orderDesc("$updatedAt"), Query.limit(6),Query.search('userName', id)];
if (pageParam) {
queries.push(Query.cursorAfter(pageParam.toString()));
}
try {
console.log(id);
let posts = await this.database.listDocuments(
conf.DATABASE_ID,
conf.USER,
queries
);
if (!posts) throw Error;
console.log(posts);
return posts;
} catch (error) {
console.log(error);
}
}```

this is the function which gets the searched result

TypeScript
export const useGetInfinityUserSearch = (id:string) => {
return useInfiniteQuery({
queryKey: [QUERY_KEYS.GET_INFINITE_USER_SEARCH],
queryFn: ({ pageParam }) =>{
console.log(id);
return authservice.getInfiniteUserResult({id:id, pageParam:pageParam})
},
getNextPageParam: (lastPage ) => {
if (lastPage && lastPage.documents.length === 0) {
return null;
}
const lastId = lastPage?.documents[lastPage.documents.length - 1].$id;
console.log(lastPage);
return lastId;
},
});
};```
This is react-query
Recommended threads
- Document Permissions ... User array vs T...
In my app, I will have multiple users who need read accesss a document, but ONLY them. Sometimes its 2 people and sometimes it will be 100 but sometimes 5000. ...
- i just have new account and give me this
Phone authentication limit for your organization has exceeded. Please upgrade to a higher plan or update your budget cap. this my first account
- Unable to get account or logout after a ...
I get the following error after a successful login when ever I call account.get() or account.deleteSession(sessionId: "current"). User (role: guests) missing sc...
