Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typeorm @unique

@Entity()
@Unique(["field1"]) // one field
@Unique("index_name", ["field1", "field2"]) // named; multiple fields
export class MyEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;
  
  @Column()
  field1: string;
  
  @Column()
  field2: string;
} 
 
PREVIOUS NEXT
Tagged: #typeorm
ADD COMMENT
Topic
Name
7+4 =