chore(utils): Update base repository to infer primary keys and support composite (#6062)
This commit is contained in:
@@ -14,6 +14,11 @@ type CreateProductCollection = ProductTypes.CreateProductCollectionDTO & {
|
||||
export class ProductCollectionRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
|
||||
ProductCollection
|
||||
) {
|
||||
constructor(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
}
|
||||
|
||||
async create(
|
||||
data: CreateProductCollection[],
|
||||
context: Context = {}
|
||||
|
||||
@@ -7,6 +7,11 @@ import { DALUtils } from "@medusajs/utils"
|
||||
export class ProductImageRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
|
||||
Image
|
||||
) {
|
||||
constructor(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
}
|
||||
|
||||
async upsert(urls: string[], context: Context = {}): Promise<Image[]> {
|
||||
const manager = this.getActiveManager<SqlEntityManager>(context)
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
export class ProductOptionValueRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
|
||||
ProductOptionValue
|
||||
) {
|
||||
constructor(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
}
|
||||
|
||||
async upsert(
|
||||
optionValues: (UpdateProductOptionValueDTO | CreateProductOptionValueDTO)[],
|
||||
context: Context = {}
|
||||
|
||||
@@ -10,6 +10,11 @@ export class ProductOptionRepository extends DALUtils.mikroOrmBaseRepositoryFact
|
||||
update: ProductTypes.UpdateProductOptionDTO
|
||||
}
|
||||
>(ProductOption) {
|
||||
constructor(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
}
|
||||
|
||||
async create(
|
||||
data: ProductTypes.CreateProductOptionDTO[],
|
||||
context: Context = {}
|
||||
|
||||
@@ -15,6 +15,11 @@ export class ProductTagRepository extends DALUtils.mikroOrmBaseRepositoryFactory
|
||||
update: UpdateProductTagDTO
|
||||
}
|
||||
>(ProductTag) {
|
||||
constructor(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
}
|
||||
|
||||
async upsert(
|
||||
tags: UpsertProductTagDTO[],
|
||||
context: Context = {}
|
||||
|
||||
@@ -14,6 +14,11 @@ export class ProductTypeRepository extends DALUtils.mikroOrmBaseRepositoryFactor
|
||||
update: UpdateProductTypeDTO
|
||||
}
|
||||
>(ProductType) {
|
||||
constructor(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
}
|
||||
|
||||
async upsert(
|
||||
types: CreateProductTypeDTO[],
|
||||
context: Context = {}
|
||||
|
||||
@@ -14,4 +14,9 @@ export class ProductVariantRepository extends DALUtils.mikroOrmBaseRepositoryFac
|
||||
"id"
|
||||
>
|
||||
}
|
||||
>(ProductVariant) {}
|
||||
>(ProductVariant) {
|
||||
constructor(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,11 @@ export class ProductRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
|
||||
create: WithRequiredProperty<ProductTypes.CreateProductOnlyDTO, "status">
|
||||
}
|
||||
>(Product) {
|
||||
constructor(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
}
|
||||
|
||||
async find(
|
||||
findOptions: DAL.FindOptions<Product & { q?: string }> = { where: {} },
|
||||
context: Context = {}
|
||||
|
||||
Reference in New Issue
Block a user