-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Package
- db
Description / Use Case for a Feature
Currently it is not possible to define a default expression for relations. This was possible with GQL-Type-Definitions.
Example:
@Entity()
export default class Post extends BaseEntity {
@PrimaryGeneratedColumn()
public id: string;
@Column({ gqlType: "String", type: "character varying" })
public title: string;
@ManyToOne((type) => User, "posts", { default: () => { return "_auth.current_user_id()" } })
public owner: User;
}
If I don't allow to set the owner over GQL the post will be owned by the current user by default without forcing the user to submit an ownerId.
Maybe this is relevant: typeorm/typeorm#2427
mirogajdos and TomMarius