Skip to content

Commit

Permalink
refactor: migrate cart module to DML (medusajs#10385)
Browse files Browse the repository at this point in the history
FIXES: FRMW-2815

This PR has no breaking changes
  • Loading branch information
thetutlage authored and hirotaka committed Dec 7, 2024
1 parent 4ab1804 commit 6b2cd2b
Show file tree
Hide file tree
Showing 16 changed files with 805 additions and 1,272 deletions.
6 changes: 6 additions & 0 deletions .changeset/sour-cats-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/cart": patch
"@medusajs/utils": patch
---

refactor: migrate cart module to DML
1 change: 1 addition & 0 deletions packages/core/utils/src/dml/relations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./has-many"
export * from "./has-one"
export * from "./many-to-many"
export * from "./nullable"
export * from "./has-one-fk"
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { CreateCartDTO } from "@medusajs/framework/types"
import { CreateCartDTO, InferEntityType } from "@medusajs/framework/types"
import { SqlEntityManager } from "@mikro-orm/postgresql"
import { Cart } from "../../../src/models"
import { defaultCartsData } from "./data"
import { toMikroORMEntity } from "@medusajs/framework/utils"

export * from "./data"

export async function createCarts(
manager: SqlEntityManager,
cartsData: CreateCartDTO[] = defaultCartsData
): Promise<Cart[]> {
const carts: Cart[] = []
): Promise<InferEntityType<typeof Cart>[]> {
const carts: InferEntityType<typeof Cart>[] = []

for (let cartData of cartsData) {
let cart = manager.create(Cart, cartData)
let cart = manager.create(toMikroORMEntity(Cart), cartData)

await manager.persistAndFlush(cart)
}
Expand Down
Loading

0 comments on commit 6b2cd2b

Please sign in to comment.