You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// src/models/post.tsimport{BeforeInsert,Column,Entity,JoinColumn,ManyToOne,}from'typeorm'import{BaseEntity}from'@medusajs/medusa'import{generateEntityId}from'@medusajs/medusa/dist/utils'import{User}from'@medusajs/medusa'// I think this should not be './user' ?
@Entity()exportclassPostextendsBaseEntity{
@Column({type: 'varchar'})title: string|null
@Column({type: 'varchar'})author_id: string
@ManyToOne(()=>User,(user)=>user.posts)// <- Here property not exists
@JoinColumn({name: 'author_id'})author: User
@BeforeInsert()privatebeforeInsert(){this.id=generateEntityId(this.id,"post")}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was trying to extend the
User
entity according to this Document. But I met something confusing.And the
Post
entity from the tutorialAnd the declaration file
And There are two errors on
![image](https://private-user-images.githubusercontent.com/48652450/266186224-d7552739-cd92-4655-90f1-3aa9d6874835.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMzE4MzcsIm5iZiI6MTcyNDEzMTUzNywicGF0aCI6Ii80ODY1MjQ1MC8yNjYxODYyMjQtZDc1NTI3MzktY2Q5Mi00NjU1LTkwZjEtM2FhOWQ2ODc0ODM1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIwVDA1MjUzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ3Mjg0OGM2M2U3Y2U2ZmRmZDk4YjU5NTQ4N2UwNzhkOTI4NTdkYmE3YmEzM2QxNWM0NjE1OWIwYzhjNjEyOGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zYkm6tw6_sqRNv1yeFRIcCS3yEkJdUV9-Vkt-iF6BoU)
![image](https://private-user-images.githubusercontent.com/48652450/266186783-ea50f34d-a04d-4cb4-bd33-8b7e4c2a97e6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMzE4MzcsIm5iZiI6MTcyNDEzMTUzNywicGF0aCI6Ii80ODY1MjQ1MC8yNjYxODY3ODMtZWE1MGYzNGQtYTA0ZC00Y2I0LWJkMzMtOGI3ZTRjMmE5N2U2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIwVDA1MjUzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQwNjRmZDkzOGU4Y2JkMGE0YTcxZjhmNjMzOWQxMDdiYTFhYzRkOTU4N2UwNDBiMWE5NDc1YzlkZDg1NjlmZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.HiCh2W8hMHWkUsKq_Mky8ZuKFTRBSVKT70nXjic8nyQ)
index.d.ts
I've looking through the issues and discussions, but not found any solution. If there is something I missed, my bad.
Beta Was this translation helpful? Give feedback.
All reactions