typeorm#Unique TypeScript Examples

The following examples show how to use typeorm#Unique. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Match.ts    From vsinder with Apache License 2.0 6 votes vote down vote up
@Unique(["userId1", "userId2"])
@Entity()
export class Match extends BaseEntity {
  @PrimaryGeneratedColumn("uuid")
  id: string;

  @Column()
  userId1: string;

  @ManyToOne(() => User, (u) => u.matches1, {
    onDelete: "CASCADE",
  })
  @JoinColumn({ name: "userId1" })
  user1: Promise<User>;

  @Column()
  userId2: string;

  @ManyToOne(() => User, (u) => u.matches2, {
    onDelete: "CASCADE",
  })
  @JoinColumn({ name: "userId2" })
  user2: Promise<User>;

  @Column("boolean", { default: false })
  read1: boolean;

  @Column("boolean", { default: false })
  read2: boolean;

  @Column("boolean", { default: false })
  unmatched: boolean;

  @OneToMany(() => Message, (m) => m.match)
  messages: Promise<Message[]>;

  @CreateDateColumn({ type: "timestamp with time zone" })
  createdAt: Date;
}
Example #2
Source File: user.entity.ts    From nestjs-starter-rest-api with MIT License 5 votes vote down vote up
@Unique('username', ['username'])
  @Column({ length: 200 })
  username: string;
Example #3
Source File: user.entity.ts    From nestjs-starter-rest-api with MIT License 5 votes vote down vote up
@Unique('email', ['email'])
  @Column({ length: 200 })
  email: string;
Example #4
Source File: user.entity.ts    From nodejs-angular-typescript-boilerplate with Apache License 2.0 5 votes vote down vote up
@Column()
    @Unique(["email"])
    email: string;