#Extend an Entity

6 messages · Page 1 of 1 (latest)

delicate sedge
#

i am trying to extend product entity but facing error
Module '"@drifting gardenjs/medusa/dist/loaders/database"' has no exported member 'dataSource'. Did you mean to use 'import dataSource from "@drifting gardenjs/medusa/dist/loaders/database"' instead?ts(2614)
"dependencies": {
"@drifting gardenjs/medusa": "^1.6.0",
"@drifting gardenjs/medusa-cli": "^1.3.3"
}

Reference : https://docs.medusajs.com/development/entities/extend-entity

Learn how to extend a core entity in Medusa to add custom attributes.

frigid basin
#

You are using a very old version of Medusa, and need to upgrade to at least v. 1.8 🙂

delicate sedge
#

Still not able to compile the code

"dependencies": {
"@drifting gardenjs/event-bus-redis": "^1.8.3",
"@drifting gardenjs/medusa": "^1.8.0",
"@drifting gardenjs/medusa-cli": "^1.3.11",
"api": "^5.0.7",
"medusa-file-s3": "^1.1.8",
"medusa-fulfillment-manual": "^1.1.31",
"medusa-interfaces": "^1.3.7",
"medusa-payment-manual": "^1.0.23",
"medusa-payment-stripe": "^2.0.2",
"sqlite3": "^5.1.4",
"typeorm": "^0.3.11"
}
ERROR:

delicate sedge
#

Anyone can please let me know what's wrong with it?

delicate sedge
#

Anyone??

foggy oar
#

Hey, I managed to successfully upgrade my marketplace from 1.7.x to 1.8.x

When you go to @medusajs/medusa/dist/loaders/database do you see the file ?
Make sure that you have installed the correct versions, also try to remove the node_modules folder and reinstall again

My code is the same as yours :

import { Product } from '../models/product'
import { dataSource } from '@medusajs/medusa/dist/loaders/database'
import { ProductRepository as MedusaProductRepository } from '@medusajs/medusa/dist/repositories/product'

export const ProductRepository = dataSource.getRepository(Product).extend({
    ...Object.assign(MedusaProductRepository, { target: Product }),
})

export default ProductRepository