공부/MongoDB
-
[MongoDB] data types공부/MongoDB 2022. 1. 11. 23:39
text boolean - true/false number - NumberInt (int32) / NumberLong (int64) / NumberDecimal shell에 숫자를 입력하면 기본적으로 float형(64bit)으로 저장함. mongodb shell이 javascript 기반인데, javascript는 integer와 floating point value 간 구분을 하지 않기 때문 ObjectId ISODate("2022-01-11") / Timestamp(1641908460) Embedded Document Array
-
[MongoDB] embedded documents & arrays공부/MongoDB 2022. 1. 9. 23:18
embedded document MongoDB에서는 field의 value가 또 하나의 document 형식을 가질 수 있다. limits : 최대 100 levels of nesting document 1개의 최대 용량: 16MB status라는 embedded document를 추가함 embedded document 접근 방법 찾고자하는 value의 path를 " "로 감싸줘야함 array 어떠한 데이터 형식이든 추가 가능 (strings, number, json 등) hobbies라는 array를 추가함. embedded document가 아님 ❗ array 접근 방법
-
[MongoDB] find( )공부/MongoDB 2022. 1. 9. 21:42
collection에 insertMany( )를 통해 여러개의 document를 삽입 후 find( ).pretty( )를 통해 조회해보면 모든 데이터가 조회되지 않음을 확인할 수 있다. find( ) 명령어 사용 시, shell에서는 기본적으로 20개의 document만 화면에 보여주고 cursor를 반환한다. it 명령어를 치면 나머지 데이터를 조회할 수 있다. find( ).toArray( ) 메소드 사용 시: 모든 document를 fetch하여 배열로 반환함 find( ).forEach( ) : 모든 document에 접근하여 사용자가 지정한 명령을 수행함. 아래에서는 printjson( ) 명령어를 수행한 것임 findOne( ).pretty( ) 가 에러나는 이유: findOne( )은 cu..
-
[MongoDB] CRUD Operations공부/MongoDB 2022. 1. 9. 19:24
Create insertOne(data, options) 👉 하나의 document를 삽입함 insertMany(data, options) 👉 여러 document를 삽입함 Read find(filter, options) 👉 collection의 모든 document를 조회함 findOne(filter, options) 👉 filter를 만족하는 첫번째 document를 조회함 Update updateOne(filter, data, options) 👉 filter를 만족하는 첫번째 document를 수정함 updateMany(filter, data, options) 👉 filter를 만족하는 모든 document를 수정함 replaceOne(filter, data, options) 👉 filter를 만족..