0
이하 json은 내 컬렉션의 문서 구조를 나타냅니다.MongoDB의 배열 열을 제외 할 쿼리
{
"_id" : ObjectId("591a653c366df19100ed0fbc"),
"sno" : 1,
"chapterName" : "chapter 1: Express JS",
"overView" : "Overview of Express JS",
"sections" : [
{
"title" : "The Node.js philosophy",
"subSections" : [
{
"sno" : 1,
"title" : "Small core 1",
"content" : "The Node.js core itself has its foundations 1"
},
{
"sno" : 2,
"title" : "Small core 2",
"content" : "The Node.js core itself has its foundations 2"
}
]
},
{
"title" : "The Node.js philosophy 2",
"subSections" : [
{
"sno" : 1,
"title" : "Small core 1",
"content" : "The Node.js core itself has its foundations 1"
},
{
"sno" : 2,
"title" : "Small core 2",
"content" : "The Node.js core itself has its foundations 2"
}
]
}
]
}
("내용"제외) 내가 아래에 언급 된 방법으로 모든 레코드에 대한 데이터를 반환하는 쿼리를 작성하고 싶습니다
{
"_id" : ObjectId("591a653c366df19100ed0fbc"),
"sno" : 1,
"chapterName" : "chapter 1: Express JS",
"overView" : "Overview of Express JS",
"sections" : [
{
"title" : "The Node.js philosophy",
"subSections" : [
{
"sno" : 1,
"title" : "Small core 1"
},
{
"sno" : 2,
"title" : "Small core 2"
}
]
},
{
"title" : "The Node.js philosophy 2",
"subSections" : [
{
"sno" : 1,
"title" : "Small core 1"
},
{
"sno" : 2,
"title" : "Small core 2"
}
]
}
]
}
어떤 생각이 어떻게 실현하려?
가능합니다. 하지만 배열을 중첩하지 않아야합니다. 배열을 업데이트하는 방법에 제한이 있습니다. 따라서 가능한 한 쉽지는 않지만 문서 구조를 조금만 편다면 훨씬 간단하고 효율적입니다. 하나의 배열을 다른 배열에 중첩하지 않고 단일 배열의 항목에 대한 속성을 생각하십시오. –