Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Default value in relations #120

Open
dustin-H opened this issue Sep 19, 2019 · 0 comments
Open

Feature Request: Default value in relations #120

dustin-H opened this issue Sep 19, 2019 · 0 comments
Assignees

Comments

@dustin-H
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants