From 984d7f9f13db7f02f77cc041486e5777c0912174 Mon Sep 17 00:00:00 2001 From: Temux Ocit Date: Mon, 16 Oct 2023 15:38:01 +0700 Subject: [PATCH] update --- actions/getListings.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/actions/getListings.ts b/actions/getListings.ts index 3184bf2..40d0ec1 100644 --- a/actions/getListings.ts +++ b/actions/getListings.ts @@ -1,8 +1,24 @@ import prisma from '@/libs/prismadb'; -export default async function getListings() { +export interface IListingParams{ + userId?:string +} + +export default async function getListings( + params:IListingParams +) { + + const {userId}= params + + let query:any={} + + if (userId){ + query.userId=userId + } + try { const listings = await prisma.listing.findMany({ + where:query, orderBy: { createdAt: 'desc' }