Answers for "typeorm relation id"

0

typeorm relation id

/*
* Loads id (or ids) of specific relations into properties. 
* For example, if you have a many-to-one category in your 
*  Post entity, you can have a new category id by marking 
*  a new property with @RelationId. Example:
*/

@Entity()
export class Post {

    @ManyToOne(type => Category)
    category: Category;

    @RelationId((post: Post) => post.category) // you need to specify target relation
    categoryId: number;

}
Posted by: Guest on March-23-2022

Code answers related to "TypeScript"

Browse Popular Code Answers by Language