Spaces:
Sleeping
Sleeping
File size: 1,152 Bytes
7f81110 | 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 27 28 29 30 31 32 33 | import { eq } from "drizzle-orm";
import { orderLineItems, NewOrderLineItem } from "../schema/orderLineItems";
import { IPgOrderLineItemRepository } from "./IPgOrderLineItemRepository";
export class PgOrderLineItemRepository implements IPgOrderLineItemRepository {
constructor(private readonly db: any) { }
async upsert(input: NewOrderLineItem): Promise<void> {
await this.db
.insert(orderLineItems)
.values(input)
.onConflictDoUpdate({
target: [orderLineItems.storeId, orderLineItems.shopifyId],
set: {
title: input.title,
variantId: input.variantId,
productId: input.productId,
sku: input.sku,
quantity: input.quantity,
price: input.price,
data: input.data,
updatedAt: new Date(),
},
});
}
async deleteByOrder(orderId: string): Promise<void> {
await this.db
.delete(orderLineItems)
.where(eq(orderLineItems.orderId, orderId));
}
}
|