From 64fb1f7ac94d5b9bb43bdc46dc12bd282ea5b223 Mon Sep 17 00:00:00 2001 From: Leon Xu Date: Sat, 30 Dec 2023 14:17:09 -0800 Subject: [PATCH] feat: created getAllProducts feature --- lib/actions/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/actions/index.ts b/lib/actions/index.ts index 56a422d..3b1a06e 100644 --- a/lib/actions/index.ts +++ b/lib/actions/index.ts @@ -59,4 +59,16 @@ export async function getProductById(productId: string) { } catch (error) { console.log(error); } +} + +export async function getAllProducts() { + try { + connectToDB(); + + const products = await Product.find(); + + return products + } catch (error) { + console.log(error); + } } \ No newline at end of file