|
1
|
import { Price } from "@models" |
|
2
|
import { defaultPricesData } from "./data" |
|
3
|
import { SqlEntityManager } from "@medusajs/framework/mikro-orm/postgresql" |
|
4
|
import { toMikroORMEntity } from "@medusajs/framework/utils" |
|
5
|
|
|
6
|
export * from "./data" |
|
7
|
|
|
8
|
export async function createPrices( |
|
9
|
manager: SqlEntityManager, |
|
10
|
pricesData: any[] = defaultPricesData |
|
11
|
): Promise<Price[]> { |
|
12
|
const prices: Price[] = [] |
|
13
|
|
|
14
|
for (let data of pricesData) { |
|
15
|
const price = manager.create(toMikroORMEntity(Price), data) |
|
16
|
prices.push(price) |
|
17
|
} |
|
18
|
|
|
19
|
await manager.persistAndFlush(prices) |
|
20
|
|
|
21
|
return prices |
|
22
|
} |