https://www.mongodb.com/docs/v4.4/crud/#delete-operations MongoDB CRUD Operations — MongoDB Manual Docs Home → MongoDB Manual CRUD operations create, read, update, and delete documents.You can connect with driver methods and perform CRUD operations for deployments hosted in the following environments:MongoDB Atlas: The fully managed service for MongoD www.mongodb.com 단일 문서 삭제 ( deleteOne(필터) ) d..
https://www.mongodb.com/docs/v4.4/reference/update-methods/ Update Methods — MongoDB Manual Docs Home → MongoDB Manual MongoDB provides the following methods for updating documents in a collection:Updates at most a single document that match a specified filter even though multiple documents may match the specified filter.Update all documents th www.mongodb.com 단일 문서 수정 ( updateOne(필터, 업데이트), $se..
https://www.mongodb.com/docs/v4.4/reference/insert-methods Insert Methods — MongoDB Manual Docs Home → MongoDB Manual MongoDB provides the following methods for inserting documents into a collection:If you use MongoDB Atlas, the fully managed service for MongoDB deployments in the cloud, you can use these methods to insert documents after you www.mongodb.com _id 속성을 명시하지 않으면 자동으로 생성된다. ( pk 역할, ..
중첩 JSON이란? 순서와 값이 중요 : { } 사용 db.컬렉션.find({key:{k1:v1,k2:v2}}) > db.user2.find({comments:{email:'hong@example.com', content:'nice post'}}) // 1개 > db.user2.find({comments:{email:'hong@example.com'}}) // 0개, 값의 갯수가 다름 >db.user2.find({comments:{content:'nice post', email:'hong@example.com'}}) // 0개, 순서다름 순서와 값이 무관 : . 사용 db.컬렉션.find({”key.k1”:value1, “key.k2”:value2}) > db.user2.find({"comments.em..
⇒ tutorial.user2.json 데이터 사용 ⇒ user가 tutorial로 안되어있을 경우 > use tutorial 입력 값으로 조회 db.컬렉션.find({key:value}) grade 배열에 A가 있는 모든 값 출력 > db.user2.find({grade:’A’}) > db.user2.find({grade:’A’}).count() 배열형식의 조회는 순서가 정확하게 일치해야 된다. db.컬렉션.find({key:[v1,v2,v3]}) > db.user2.find({grade:['A','B','C']}) 하나 이상의 배열 요소와 일치하는 값 반환 : $all $all ⇒ 배열의 순서 및 갯수 무관, 값의 일치여부만 확인 db.컬렉션.find({key:{$all:[v1,v2]}}) > db...
db.컬렉션명.find(query(행선택), projection(열선택)) 컬럼선택(1) 또는 제거(0) 를 명시하는 방법으로 열 선택한다. _id 제외한 나머지 열은 0과 1 혼합 불가 _id는 pk역할이고 필수. 무조건 검색된다. > db.user.find({ }, {username:1}) //전체행에서 username만 선택 > db.user.find({ }, {username:1, gender:1}) //전체행에서 username, gender 선택 > db.user.find({ }, {username:0}) //전체행에서 username만 빼고 다 선택 > db.user.find({ }, {username:1, gender:0}) //1과 0을 혼합해서 못 쓴다. 에러 발생. > db.user...
💡 https://www.mongodb.com/docs/v4.4/reference/method/db.collection.find/ 전체조회 db.컬렉션명.find(query(행선택), projection(열선택)) db.user.find() db.user.find({ }) 조건 지정 db.컬렉션명.fing({key:value}) db.user.find({age:56}) db.user.find({gender:‘f’}) https://www.mongodb.com/docs/manual/reference/operator/query/#logical and 조건지정 db.컬렉션명.find({key:value, key1:value1}) db.user.find({gender:‘f’, age:1..