简体   繁体   中英

How to implement an interface in an Entity using typeorm

I'm using an entity "User" but I need to implement the currentMatch the user is playing so I did something like this

@Column({
nullable: true,
})
public currentMatch: Match;

Where Match is an interface with all the data I need from the match.

ERROR [ExceptionHandler] Data type "Match" in "UserEntity.currentMatch" is not supported by "postgres" database.

Is there a way to implement my interface to the entity?

You can try adding type: 'json'

@Column({
nullable: true,
type: 'json'
})
public currentMatch: Match;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM