MongoDB - Document Query(조회) - (2)

2021. 12. 18. 11:23·Database/MongoDB
728x90
💡 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: 21, uom

docs.mongodb.com

 

 

포함/중첩 document에 대한 Query

  • 포함/중첩 document 일치document{ : }를 사용한다. 여기서 는 일치시킬 document이다.
  • 포함/중첩된 document에 사용되는 필드에 동등 조건을 지정하려면 쿼리 필터

ex) inventory 컬렉션의 size 필드가 equals the document { h: 14, w: 21, uom: "cm" }:

db.inventory.find( { size: { h: 14, w: 21, uom: "cm" } } )
  • 중첩 field에 대한 쿼리포함/중첩 document에 대한 쿼리

포함/중첩 document 필드에 쿼리 조건을 지정하려면 점 표기법을 사용한다.

dot notation ("field.nestedField").

<참고> → 점 표기법을 사용하여 쿼리할 때 필드와 중첩 필드는 따옴표 안에 있어야 합니다.

ex) size 필드에 중첩된 uom 필드에 “in”인 모든 document 선택

db.inventory.find( { "size.uom": "in" } )

ex) size 필드에 중접된 h 필드에 less than operator 인 $lt을 사용해서 선택

db.inventory.find( { "size.h": { $lt: 15 } } )

ex) AND 연산자 사용한 검색

db.inventory.find( { "size.h": { $lt: 15 }, "size.uom": "in", status: "D" } )
728x90
반응형

'Database > MongoDB' 카테고리의 다른 글

MongoDB - 배열 쿼리 - (2)  (0) 2021.12.19
MongoDB - 배열 쿼리 - (1)  (1) 2021.12.19
MongoDB - Document Query(조회) - (1)  (0) 2021.12.18
MongoDB - Database/Collection/Document생성,제거  (0) 2021.12.18
MongoDB - 데이터 모델링  (1) 2021.12.18
'Database/MongoDB' 카테고리의 다른 글
  • MongoDB - 배열 쿼리 - (2)
  • MongoDB - 배열 쿼리 - (1)
  • MongoDB - Document Query(조회) - (1)
  • MongoDB - Database/Collection/Document생성,제거
pink_salt
pink_salt
유익함을 주는 개발자가 되도록 keep going
  • pink_salt
    KeepGoingForever
    pink_salt
  • 전체
    오늘
    어제
    • 분류 전체보기 (117)
      • Project (7)
      • WEB study (3)
        • WEB(Springboot) (10)
        • Git, GitLab (13)
        • Clean code (1)
        • FrontEnd (3)
      • Study (21)
        • Algorithm (19)
        • 면접 준비 (2)
      • Cloud Computing (2)
        • AWS (2)
      • 프로그래밍 언어 (35)
        • Java (29)
        • Python (0)
        • javascript (6)
      • 운영체제 (0)
        • Linux (0)
      • Database (4)
        • MongoDB (8)
        • SQL (8)
      • 애플리케이션 개발 (1)
        • Android (1)
      • AI (1)
        • Deeplearning (1)
        • machinelearning (0)
      • Daily (0)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    개념
    코드프레소
    gitlab
    mysql
    python
    spring boot
    무료IT교육
    티스토리챌린지
    Git
    대외활동
    git branch
    빅오표기법
    codepresso
    MongoDB
    객체지향
    코딩강의
    SWEA
    백준
    언어
    Query
    코딩이러닝
    SW
    dp
    BFS
    자바
    무료코딩교육
    Java
    IT교육
    Database
    오블완
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.4
pink_salt
MongoDB - Document Query(조회) - (2)
상단으로

티스토리툴바