-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad51b61
commit 23dd46b
Showing
8 changed files
with
34 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,11 @@ | ||
import { Context } from "@medusajs/types" | ||
import { DALUtils } from "@medusajs/utils" | ||
import { SqlEntityManager } from "@mikro-orm/postgresql" | ||
import { Address } from "@models" | ||
import { CreateAddressDTO, UpdateAddressDTO } from "../types" | ||
|
||
export class AddressRepository extends DALUtils.mikroOrmBaseRepositoryFactory< | ||
Address, | ||
{ | ||
create: CreateAddressDTO | ||
update: UpdateAddressDTO | ||
} | ||
>(Address) { | ||
async update( | ||
data: { address: Address; update: UpdateAddressDTO }[], | ||
context: Context = {} | ||
): Promise<Address[]> { | ||
const manager = this.getActiveManager<SqlEntityManager>(context) | ||
|
||
const entities = data.map(({ address, update }) => { | ||
return manager.assign(address, update) | ||
}) | ||
|
||
manager.persist(entities) | ||
|
||
return entities | ||
} | ||
} | ||
>(Address) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,11 @@ | ||
import { Context } from "@medusajs/types" | ||
import { DALUtils } from "@medusajs/utils" | ||
import { SqlEntityManager } from "@mikro-orm/postgresql" | ||
import { LineItem } from "@models" | ||
import { UpdateLineItemDTO } from "../types" | ||
import { CreateLineItemDTO, UpdateLineItemDTO } from "../types" | ||
|
||
export class LineItemRepository extends DALUtils.mikroOrmBaseRepositoryFactory<LineItem>( | ||
LineItem | ||
) { | ||
async update( | ||
data: { lineItem: LineItem; update: UpdateLineItemDTO }[], | ||
context: Context = {} | ||
): Promise<LineItem[]> { | ||
const manager = this.getActiveManager<SqlEntityManager>(context) | ||
|
||
const entities = data.map(({ lineItem, update }) => { | ||
return manager.assign(lineItem, update) | ||
}) | ||
|
||
manager.persist(entities) | ||
|
||
return entities | ||
export class LineItemRepository extends DALUtils.mikroOrmBaseRepositoryFactory< | ||
LineItem, | ||
{ | ||
create: CreateLineItemDTO | ||
update: UpdateLineItemDTO | ||
} | ||
} | ||
>(LineItem) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters