// client
const { results, isLoading, status, loadMore } = usePaginatedQuery(
api.user.getUserEquips,
{ userId, type: "mana" },
{ initialNumItems: 5 }
);
// server
export const getUserEquips = query({
args: {
paginationOpts: paginationOptsValidator,
userId: v.union(v.string(), v.null()),
type: v.union(v.string(), v.null()),
},
handler: async ({ db }, { userId, type }) => {
if (
userId === null ||
userId === undefined ||
type === null ||
type === undefined
) {
return;
}
return await db
.query("userEquips")
.withIndex("by_userId_type", (q) =>
q.eq("userId", userId).eq("type", type)
)
.order("desc")
.paginate(args.paginationOpts);
},
});
// client
const { results, isLoading, status, loadMore } = usePaginatedQuery(
api.user.getUserEquips,
{ userId, type: "mana" },
{ initialNumItems: 5 }
);
// server
export const getUserEquips = query({
args: {
paginationOpts: paginationOptsValidator,
userId: v.union(v.string(), v.null()),
type: v.union(v.string(), v.null()),
},
handler: async ({ db }, { userId, type }) => {
if (
userId === null ||
userId === undefined ||
type === null ||
type === undefined
) {
return;
}
return await db
.query("userEquips")
.withIndex("by_userId_type", (q) =>
q.eq("userId", userId).eq("type", type)
)
.order("desc")
.paginate(args.paginationOpts);
},
});