
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
- Processing forever
Why is this processing forever?
- Migration to new region: not so good.
We attempted to do a migration to NYC... and things didn't go well. We followed the steps (exactly) as shown in the video, updated our app with the new endpoint...
- schedule functions not working
starting from 15:02 utc time my schedule function stops working. I was able to execute it using the GUI. The schedule is every 5 minutes and I can see a clock i...
