티스토리 뷰
/**
* Set's LIMIT - maximum number of rows to be selected.
* NOTE that it may not work as you expect if you are using joins.
* If you want to implement pagination, and you are having join in your query,
* then use instead take method instead.
*/
limit(limit?: number): this;
/**
* Set's OFFSET - selection offset.
* NOTE that it may not work as you expect if you are using joins.
* If you want to implement pagination, and you are having join in your query,
* then use instead skip method instead.
*/
offset(offset?: number): this;
/**
* Sets maximal number of entities to take.
*/
take(take?: number): this;
/**
* Sets number of entities to skip.
*/
skip(skip?: number): this;
공통점
- limit와 take : 불러오는 콘텐츠 개수
- offset과 skip : 몇 번째 콘텐츠부터 출력할지
차이점
- limit와 offset : join하기 전에 실행 - row 기준, join 했을 때 join을 한 모든 테이블의 row에 적용된다
- user 테이블에 post를 join하고 limit 5를 적용했다면
: user만 5개 불러와지는 게 아니라 join된 post의 row도 5개까지만 불러온다. - take와 skip : join 후에 실행 - entity 기준
'라이브러리, 프레임워크 > TypeORM' 카테고리의 다른 글
[TypeORM + NestJS] select 시 oneToMany 관계 count 해서 함께 조회하기 (loadRelationCountAndMap) (0) | 2023.01.05 |
---|---|
[TypeORM + NestJS] 일기 생성 API - oneToMany, manyToMany save 로직 기록 (0) | 2023.01.01 |
[TypeORM + NestJS] optional 하게 조건절 사용하기 (0) | 2022.08.03 |
[TypeORM + NestJS] Unknown column 'distinctAlias.User_id' in 'field list'" 에러 (0) | 2022.07.21 |
[TypeORM] 페이징 처리 문법 (0) | 2022.07.15 |
댓글