-
Mongoose를 사용하는 이유가 뭘까?스터디노트/알게된 내용 정리하기 2023. 3. 21. 14:16
팀에서 Database로 MongoDB를 사용하고 ODM으로 Mongoose를 사용하고 있다. 개인 프로젝트에서 MySQL을 사용하고 ORM으로 sequelize를 사용할 때와 팀에서 ODM으로 Mongoose를 사용하면서 ORM, ODM을 사용하는 근본적인 이유가 궁금해졌다. 왜냐하면 프로젝트 요구사항을 파악했을 때 ORM, ODM을 사용하지 않아도 있을 수 있다고 생각했기 때문이다.
ORM, ODM을 사용하게 되면 DB에서 조회할 때 document를 자바스크립트 객체로 바꿔준다는 것 외에 다른 자세한 이유도 학습하기로 했다.
Mongoose란??
- MongoDB를 위한 ODM (Object Data Modeling) 라이브러리
- 데이터 모델링 간소화
- 스키마 기반 접근 방식으로 데이터 일관성을 더 쉽게 검증하고 적용할 수 있다.
- 미들웨어 지원
- CRUD 미들웨어 기능을 정의할 수 있기 때문에 비즈니스 로직을 쉽게 구현할 수 있다.
- 쿼리 빌드
- 다양한 인터페이스 제공으로 MongoDB Driver에서 제공하는 raw query syntax보다 쉽다.
- Population (the process of automatically replacing the specified paths in the document with document(s) from other collection(s))
- 데이터 검색 단순화 및 수동 조인이 필요하지 않다.
- 플러그인
- 기능을 확장할 수 있는 다양한 플러그인을 제공한다.
참고자료
MongoDB & Mongoose: Compatibility and Comparison | MongoDB
Learn why using an Object Data Modeling library may not be the best choice when building MongoDB apps with Node.js.
www.mongodb.com
Introduction to Mongoose for MongoDB
by Nick Karnik Introduction to Mongoose for MongoDB Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the repre
www.freecodecamp.org
Mongoose v7.0.2: Query Population
MongoDB has the join-like $lookup aggregation operator in versions >= 3.2. Mongoose has a more powerful alternative called populate(), which lets you reference documents in other collections. Population is the process of automatically replacing the specifi
mongoosejs.com
https://www.zerocho.com/category/MongoDB/post/59b6228e92f5830019d41ac4
www.zerocho.com
'스터디노트 > 알게된 내용 정리하기' 카테고리의 다른 글
DDD(Domain Driven Design)이란? (0) 2023.03.16 else문 지양 vs 지향 && Early return (0) 2022.07.27 SQL에서 최대값 하나 출력하기 (0) 2022.03.31 UUID (0) 2021.11.18 Mocha VS Jest (0) 2021.11.08