Skip to content

Feature Request: Default value in relationsΒ #120

@dustin-H

Description

@dustin-H

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions