chore(): Reorganize modules (#7210)
**What** Move all modules to the modules directory
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export const defaultPricesData = [
|
||||
{
|
||||
id: "price-set-money-amount-USD",
|
||||
currency_code: "USD",
|
||||
amount: 500,
|
||||
title: "price set money amount USD",
|
||||
price_set_id: "price-set-1",
|
||||
rules_count: 1,
|
||||
},
|
||||
{
|
||||
id: "price-set-money-amount-EUR",
|
||||
currency_code: "EUR",
|
||||
amount: 400,
|
||||
title: "price set money amount EUR",
|
||||
price_set_id: "price-set-2",
|
||||
rules_count: 1,
|
||||
},
|
||||
{
|
||||
id: "price-set-money-amount-CAD",
|
||||
currency_code: "CAD",
|
||||
amount: 600,
|
||||
title: "price set money amount CAD",
|
||||
price_set_id: "price-set-3",
|
||||
rules_count: 1,
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { Price } from "@models"
|
||||
import { defaultPricesData } from "./data"
|
||||
|
||||
export * from "./data"
|
||||
|
||||
export async function createPrices(
|
||||
manager: SqlEntityManager,
|
||||
pricesData: any[] = defaultPricesData
|
||||
): Promise<Price[]> {
|
||||
const prices: Price[] = []
|
||||
|
||||
for (let data of pricesData) {
|
||||
const price = manager.create(Price, data)
|
||||
prices.push(price)
|
||||
}
|
||||
|
||||
await manager.persistAndFlush(prices)
|
||||
|
||||
return prices
|
||||
}
|
||||
Reference in New Issue
Block a user