allow limiting opinion count

This commit is contained in:
2024-04-19 19:29:16 +07:00
parent 4ea2a178f3
commit 8ac2815618

View File

@@ -45,7 +45,13 @@ export const userRoute = router({
)
.query(
async ({ input }) =>
await getAllUser(input.offset, input.limit, input.group, input.zone)
await getAllUser(
input.offset,
input.limit,
input.opinionCount,
input.group,
input.zone
)
),
createUser: publicProcedure
.input(
@@ -73,13 +79,16 @@ export const userRoute = router({
async function getAllUser(
offset: number,
limit: number,
opinionLimit: number,
group?: number,
zone?: number
) {
let users = await db.query.user.findMany({
with: {
group: true,
opinions: true,
opinions: {
limit: opinionLimit,
},
zone: {
with: { province: true },
},