[TIL] 0328
IT/TIL(Today I Learnt)2022. 3. 29. 13:32
Today I Learnt
0328:
몽고 db자채에있는 aggregate와 mongoose 의populate함수 비교
https://stackoverflow.com/questions/55575806/mongoose-populate-vs-aggregate
Here's a summary of the differences:
$lookup
- can only be used with aggregate
- can only be used to pull in referenced documents from unsharded collections
- can pull in referenced documents by any field
- generally more performant as it's a server-side operation
- requires MongoDB 3.2+
Mongoose populate()
- can be used with find and aggregate
- can be used to to pull in referenced documents from both sharded and unsharded collections
- can only pull in referenced documents by _id
- no MongoDB version requirement
차이점은 이렇게 정리되었다고하지만 그럼 속도는 뭐가더빠를까?
https://medium.com/cameoeng/mongodb-lookups-and-populates-an-unexpected-journey-940e08e36a94
document가 20개미만일때만, look up이빠르고 아니면 populate가더빠름.
짧지만 중요한 오늘! TIL 끝
반응형
'IT > TIL(Today I Learnt)' 카테고리의 다른 글
[TIL] 0404 - 0407 (4) | 2022.04.07 |
---|---|
[TIL] 0329 (2) | 2022.04.01 |
[TIL] 0325 프로삽질러 (5) | 2022.03.26 |
[TIL]0324 (0) | 2022.03.24 |
[TIL] 0323 세상에 믿을사람없다 (3) | 2022.03.23 |
댓글()