#Problem with extending MoneyAmountRepository

4 messages · Page 1 of 1 (latest)

zinc pecan
#

Im trying to extend MoneyAmountRepository with the following code:

  MoneyAmount,
  ProductVariant,
  ProductVariantMoneyAmount,
} from "@medusajs/medusa";
import { dataSource } from "@medusajs/medusa/dist/loaders/database";
import { MoneyAmountRepository as MedusaMoneyAmountRepository } from "@medusajs/medusa/dist/repositories/money-amount";
import { groupBy } from "lodash";
import { Brackets } from "typeorm";

export const MoneyAmountRepository = dataSource
  .getRepository(MoneyAmount)
  .extend(
    Object.assign(MedusaMoneyAmountRepository, {
      customFunction(): void {
        console.log("test");
      },
    })
  );

export default MoneyAmountRepository;```

When im trying to build i get the following error:
`Exported variable 'MoneyAmountRepository' has or is using name '_QueryDeepPartialEntity' from external module "(path)/node_modules/typeorm/query-builder/QueryPartialEntity" but cannot be named`

I've not extended the MoneyAmount model. Any ideas how i could fix it?

I've tried importing `QueryDeepPartialEntity` but it did not help
heady fulcrum
#

I have a similar challenge, I've extended the product_variant_money_amount model

but now I'm having trouble accessing the custom attributes in product_variant_money_amount in the product API

I implemented a API validator, and the loader for the product endpoint/entity

then calling the get product API endpoint, but not getting my new column returned

heady fulcrum
#

We solved our issue, we needed to extend the money_amount not the product_variant_money_amount

zinc pecan
#

I feel like our issues were quite different. I'm still stuck with mine