javascriptnode.jstypescripttypeormnode.js-typeorm

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 ?


Solution

  • You can try adding type: 'json'

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