File size: 585 Bytes
1067b6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"use server";

import { db } from "@/db/db";
import { products } from "@/db/schema";
import { CheckoutItem, OrderItemDetails } from "@/lib/types";
import { inArray } from "drizzle-orm";

export const getDetailsOfProductsOrdered = async (
  checkoutItems: CheckoutItem[]
) => {
  return (await db
    .select({
      id: products.id,
      name: products.name,
      images: products.images,
      storeId: products.storeId,
    })
    .from(products)
    .where(
      inArray(
        products.id,
        checkoutItems.map((item) => item.id)
      )
    )) as OrderItemDetails[];
};