Closed adevinwild closed 1 month ago
Oh and btw, I will suggest you a PR when I have freetime
+1, I have this problem as well.
I extended the customerGroup model with a single_customer_id
field
import { Column, Entity } from 'typeorm'
import { CustomerGroup as MedusaCustomerGroup } from '@medusajs/medusa'
@Entity()
export class CustomerGroup extends MedusaCustomerGroup {
@Column()
single_customer_id: string
}
And added it to src/index.d.ts
:
...
export declare module '@medusajs/medusa/dist/models/customer-groups' {
declare interface CustomerGroup {
single_customer_id: string
}
}
...
I added the validator as well, it all works perfectly when used with the native endpoints, I can use the single_customer_id
params for example. However, when I want to use a repo like this:
const groups = await customerGroupRepo.find({
where: { single_customer_id: req.params.id },
})
I get an error: Object literal may only specify known properties, and 'single_customer_id' does not exist in type 'FindOptionsWhere<CustomerGroup> | FindOptionsWhere<CustomerGroup>[]'.ts(2353)
How can we fix this?
Thanks!
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 3 days.
This issue was closed because it has been stalled for 3 days with no activity.
Bug report (it's not a bug technically)
Describe the bug
Hi everyone, The way the repository is resolved in the StockLocation plugin doesn't allow for optimal model extension.
Indeed, since the repository is resolved directly via the original model, it's impossible in a project to override properly the StockLocation entity without having any errors.
Let's take an example, I override the StockLocation model in my project as follows:
After the migration I'll extend the service to force this new field to be selected when retrieving stock locations :
Whenever this function is called, it will always throw an error on the terminal like this :
And it makes sense, because of the way the
StockLocationRepository
is resolved on thestock-location
module. You can check this "here"We can definitely improve this to make it more customizable, maybe by changing the way the StockLocation repo and model are resolved