
💡 MongoDB 공식문서를 참고하였다. 참고 : https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/ Project Fields to Return from Query — MongoDB Manual Docs Home → MongoDB Manual➤ Use the Select your language drop-down menu in the upper-right to set the language of the following examples.By default, queries in MongoDB return all fields in matching documents. To limit the amount of data that..

💡 MongoDB 공식 문서를 참고해서 작성하였다. 참고 : https://docs.mongodb.com/manual/tutorial/query-array-of-documents/ Query an Array of Embedded Documents — MongoDB Manual Docs Home → MongoDB Manual➤ Use the Select your language drop-down menu in the upper-right to set the language of the following examples.The following example selects all documents where an element in the instock array matches the specified do..

💡 MongoDB 공식 문서를 참고해서 작성하였다. 참고 : https://docs.mongodb.com/manual/tutorial/query-arrays/ 배열 쿼리 inventory collection 기반으로 예제를 진행한다. db.inventory.insertMany( [ { item: "journal", status: "A", size: { h: 14, w: 21, uom: "cm" }, instock: [ { warehouse: "A", qty: 5 } ] }, { item: "notebook", status: "A", size: { h: 8.5, w: 11, uom: "in" }, instock: [ { warehouse: "C", qty: 5 } ] }, { item: "paper", s..
💡 MongoDB 공식 문서를 참고해서 작성하였다. 참고 : https://docs.mongodb.com/manual/tutorial/query-embedded-documents/ Query on Embedded/Nested Documents — MongoDB Manual Docs Home → MongoDB Manual➤ Use the Select your language drop-down menu in the upper-right to set the language of the following examples.For example, the following query selects all documents where the field size equals the document { h: 14, w: ..
💡 MongoDB 공식 문서를 참고해서 작성하였다. 참고 : https://docs.mongodb.com/manual/tutorial/query-documents/ Query Documents 주어지는 예시를 통해서 db.collection.find() method를 mongosh에서 실행할 것이다. 일단 insertMany()를 통해 inventory라는 collection에 document들을 추가한다. db.inventory.insertMany([ { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" }, { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" },..

Database, Collection, Document를 생성하는 명령어와 제거하는 명령어 Database, Collection, Document 관계도 Database 생성 : use use DATABASE_NAME 명령어를 통해 Database를 생성할 수 있다. 만약 데이터베이스가 이미 존재하면 현존하는 데이터베이스를 사용한다. 생성 후에 생성된 데이터베이스를 사용하게 된다. ex) mongodb_tutorial이라는 데이터베이스를 생성한다. > use mongodb_tutorial switched to db mongodb_tutorial ex) 현재 사용 중인 데이터베이스를 확인하려면 db명령어를 입력한다. > db mongodb_tutorial ex) 만든 데이터베이스 리스트들을 확인하려면 sh..

MongoDB에서의 명령어들을 배우기 전에 MongoDB에서 데이터 모델링의 기본을 먼저 보고 가겠다. schema 디자인할 때 고려사항 사용자 요구(User Requirement)에 따라 schema를 디자인한다. 객체들을 함께 사용하게 된다면 한 Document에 합쳐서 사용한다.(ex. 게시물 - 댓글 관계) 그렇지 않으면 따로 사용해야 한다.(join은 사용하지 않는다.) 읽을 때 join하는게 아니라 데이터를 작성할 때 join한다. 예제 간단한 블로그를 위한 데이터베이스를 디자인한다고 가정한다. 요구사항 게시글에는 작성자 이름, 제목, 내용이 담겨 있다. 각 게시글은 0개 이상의 태그를 가지고 있을 수 있다. 게시글엔 댓글을 달 수 있다. 댓글은 작성자 이름, 내용, 작성 시간을 담고 있다. ..

MongoDB는 C++로 작성된 오픈소스 문서지향(Document-Oriented)적 Cross-platform 데이터베이스이다. 뛰어난 확장성과 성능을 가지고 있다. 현존하는 NoSQL데이터베이스 중 유명하다. NoSQL? Not Only SQL이다. 기존의 RDBMS의 한계를 극복하기 위해 만들어진 새로운 형태의 데이터저장소이다. 관계형 DB가 아니기 떄문에 RDMS처럼 고정된 스키마 및 JOIN이 존재하지 않는다. Document? Document Oriented 데이터베이스 여기서 말하는 Document는 RDMS의 record와 비슷한 개념이다. 데이터 구조는 한 개 이상의 key-value pair로 이루어져 있다. ex) MongoDB의 샘플 Document { "_id": ObjectId(..