TypeORM decorators

오픈소스·2023년 5월 4일
0

https://orkhan.gitbook.io/typeorm/docs/decorator-reference

  • Entity decorators
    • @Entity
    • @ViewEntity
  • Column decorators
    • @Column
      https://orkhan.gitbook.io/typeorm/docs/decorator-reference#column
      • type: ColumnType
        https://orkhan.gitbook.io/typeorm/docs/entities#column-types
        • Column types for postgres
          int, int2, int4, int8, smallint, integer, bigint, decimal, numeric, real, float, float4, float8, double precision, money, character varying, varchar, character, char, text, citext, hstore, bytea, bit, varbit, bit varying, timetz, timestamptz, timestamp, timestamp without time zone, timestamp with time zone, date, time, time without time zone, time with time zone, interval, bool, boolean, enum, point, line, lseg, box, path, polygon, circle, cidr, inet, macaddr, tsvector, tsquery, uuid, xml, json, jsonb, int4range, int8range, numrange, tsrange, tstzrange, daterange, geometry, geography, cube, ltree

      • name: string
      • length: string|number
      • width: number
      • onUpdate: string
      • nullable: boolean
      • update: boolean
      • insert: boolean
      • select: boolean
      • default: string
      • primary: boolean
      • unique: boolean
      • comment: string
      • precision: number
      • scale: number
      • zerofill: boolean
      • unsigned: boolean
      • charset: string
      • collation: string
      • enum: string[]|AnyEnum
      • enumName: string
      • primaryKeyConstraintName: string
      • asExpression: string
      • generatedType: "VIRTUAL"|"STORED"
      • hstoreType: "object"|"string"
      • array: boolean
      • transformer: ValueTransformer|ValueTransformer[]
      • spatialFeatureType: string
      • srid: number
    • @PrimaryColumn
    • @PrimaryGeneratedColumn
      https://orkhan.gitbook.io/typeorm/docs/decorator-reference#primarygeneratedcolumn
      • increment
      • identity
      • uuid
      • rowid
    • @ObjectIdColumn
    • @CreateDateColumn
    • @UpdateDateColumn
    • @DeleteDateColumn
    • @VersionColumn
    • @Generated
    • @VirtualColumn
  • Relation decorators
    • @OneToOne
      -

      @JoinColumn()은 반드시 한쪽 테이블에서만 사용해야 합니다.

    • @ManyToOne
    • @OneToMany
      -

      @OneToMany()/@ManyToOne()에서는 @JoinColumn()을 생략할 수 있습니다.
      @OneToMany()는 @ManyToOne()이 없으면 안됩니다.
      하지만 반대로 @ManyToOne()은 @OneToMany()이 없어도 정의할 수 있습니다.
      @ManyToOne()을 설정한 테이블에는 relation id가 외래키를 가지고 있게 됩니다.

    • @ManyToMany
      -

      @ManyToMany() 관계에서는 @JoinTable()이 반드시 필요합니다.
      한쪽 테이블에만 @JoinTable()을 넣어주면 됩니다.

    • @JoinColumn
    • @JoinTable
    • @RelationId
  • Subscriber and listener decorators
    • @AfterLoad
    • @BeforeInsert
    • @AfterInsert
    • @BeforeUpdate
    • @AfterUpdate
    • @BeforeRemove
    • @AfterRemove
    • @BeforeSoftRemove
    • @AfterSoftRemove
    • @BeforeRecover
    • @AfterRecover
    • @EventSubscriber
  • Other decorators
    • @Index
    • @Unique
    • @Check
    • @Exclusion

참고)

0개의 댓글