티스토리 뷰

728x90
반응형

database: mysql

- 엔티티 컬럼 길이 조정

export class Posts {
	@PrimaryGeneratedColumn({
    	type: 'int',
        name: 'postId',
        comment: '게시글 아이디'
    })
    postId: number;
    
    // 글자수 20자 제한
    @Column({ name: 'title', length: 20, comment:'게시글 제목' })
    title: string;
    
    // 글자수 200자 제한
    @Column({ name: 'content', length: 200, comment: '게시글 본문' })
    content: string;
}

https://orkhan.gitbook.io/typeorm/docs/entities

 

Entities - typeorm

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, ti

orkhan.gitbook.io


- decimal number field

@Entity({ name: 'weathers' })
export class Weathers {

	// mysql 데이터베이스에서 tempCelsius의 타입을 float 으로 지정
    @Column({ type: 'float', name: 'tempCelsius', comment: '섭씨온도' })
    tempCelsius: number;

}

 

 

 

Entities - typeorm

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, ti

orkhan.gitbook.io

 

How to properly handle decimals with TypeORM

JavaScript does not natively have a decimal type, so it will natively handle all decimals as floating points. This will create floating…

medium.com


- typeorm + mysql : 문자열길이 제한 변경

 

[MySQL] TypeORM String 타입 사용 시 문자열 길이 제한 변경

DB를 기존에 사용하던 PostgreSQL에서 MySQL로 변경하고 나서 동일한 Entity의 String 타입으로 지정된 칼럼의 문자열 길이가 공백 포함 255자 이상은 저장되지 않는 이슈가 생겼다. 기존 Entity는 Id, 생성

eight20.tistory.com


Typeorm 엔티티 데코레이션 

https://yangeok.github.io/orm/2020/12/14/typeorm-decorators.html

 

Yangeok

Yangwook Ian Jeongs' Development Blog

yangeok.github.io

 

728x90
반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함