Loading views...
mongoose 제대로 이용

mongoose 제대로 이용

Date
Date
2020 Mar 25 0:0 → 2020 Mar 26 0:0
Created by
Created by
Seonglae ChoSeonglae Cho
Created time
Created time
2023 Feb 28 12:39
Last edited by
Last edited by
Seonglae ChoSeonglae Cho
Last edited time
Last edited time
2023 Apr 15 16:53
Refs
Refs
mongo mongoose
(MongoDB) Mongoose(몽구스) 시작하기
안녕하세요. 이번 시간부터는 MongoDB ODM 중 가장 유명한 Mongoose 에 대해 알아보겠습니다. 저도 Mongoose가 너무 편리해 생 MongoDB 대신 Mongoose를 사용하고 있습니다. 일단 ODM 이 뭔지부터 알아봅시다. ODM은 Object Document Mapping의 두문자어입니다. 풀이해보면 객체와 문서를 1대1 매칭한다는 뜻인데요. Object는 자바스크립트의 객체이고, Document는 몽고DB의 문서입니다. 즉, 문서를 DB에서 조회할 때 자바스크립트 객체로 바꿔주는 역할이라고 생각하시면 됩니다.
(MongoDB) Mongoose(몽구스) 시작하기
사실 기본 몽고DB 드라이버(mongodb 패키지)도 다큐먼트(원래부터 자바스크립트지만...)를 자바스크립트 객체로 매핑하기 때문에 ODM을 쓰는 이유가 궁금하실 수도 있습니다. 어차피 자바스크립트인 것을 또 자바스크립트 객체로 매핑하는 셈이니까요
하지만 몽구스를 써본 사람들은 압니다. 왜 쓰는지를요.
몽구스의 장점을 꼽자면 강제 스키마(schema)의 부활, populate, 프로미스와 콜백 사용 가능, 편리한 쿼리 빌더 등을 꼽을 수 있습니다.
 
 
 
 
 

r&d 발표


좋았다 노sql 이해 높아짐
 
 
 
모던웹(NEMV) 혼자 제작 하기 3기 - 45 사용자 모델 정리하기
기존에는 name, age 로만 테스트 했으니 로그인이 가능할 모델로 변경합니다.
모던웹(NEMV) 혼자 제작 하기 3기 - 45 사용자 모델 정리하기
  • warning 에러잡고
코딩시작하며 느낀건데 schema 로 하려면 type meta 빼는게 더 수월하다
 
  • no versioning
[MongoDB] - Mongoose __v 제거하기
○ MongoDB Mongoose __v 제거하기 mongoose를 통해 데이터를 넣다보면 밑에 사진처럼 마지막 컬럼에 같이 __v 가 붙는다 제거 방법은 스키마를 만들 때, { versionKey : false } 를 추가하면 된다 var UserSchema..
[MongoDB] - Mongoose __v 제거하기
Mongoose versioning: when is it safe to disable it?
The version key purpose is optimistic locking. When enabled, the version value is atomically incremented whenever a document is updated. This allow your application code to test if changes have been made between a fetch (bringing in version key 42 for example) and a consequent update (ensuring version value still is 42).
Mongoose versioning: when is it safe to disable it?
이런 역할이라고 한다 버저닝 그냥 수정하면 바뀌는거 완전 몽구스에서는 안해주는듯
찾아봐야겠지만 나중에 더
 
  • no id
Stop Mongoose from creating _id property for sub-document array items
Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Provide details and share your research! Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. To learn more, see our tips on writing great answers.
Stop Mongoose from creating _id property for sub-document array items
 
notion image
흠 이건 우짤가 그냥 두긴 낭비
MongoDB - Error: document must have an _id before saving
Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Provide details and share your research! Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. To learn more, see our tips on writing great answers.
MongoDB - Error: document must have an _id before saving
흠 다 데이터 저장하긴 한다
 
 
 
 
db 설계
workspace 통합
 
 
 
 

Recommendations