feat(cart): Cart + Address services (#6055)

Duplicate of #6008, but I messed up my git history big time :'(

**What**
- CartService and CartRepository + tests
- AddressService and AddressRepository + tests
- CartModuleService skeleton. Full implementation + tests will be added in a separate PR
This commit is contained in:
Oli Juhl authored and GitHub committed 2024-01-11 14:40:13 +00:00
1 parent b6ac768698
commit ce81cade88
20 files changed
+847 -33

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
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
}
>(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
}
}