
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
- Stuck at pinging the server to finish ad...
I'm not using the starter app and I'm not sure how to finish connecting my app to Appwrite.io. Is there a CURL command I can run to finish setup?
- 500 internal error
I get a 500 internal error when trying to access my database on appwrite cloud. Sometimes it would start working but this time it never corrects.
- Error getting session: AppwriteException...
I get this error `Error getting session: AppwriteException: User (role: guests) missing scope (account)` when running in prod. As soon as I try running my app o...
