鑑於以下結構的文檔:MongoDB的tabularize嵌套陣列
{
username: "John",
subjects: [
{subjectName: "subjectA", status : "PASSED" },
{subjectName: "subjectB", status : "PASSED" },
{subjectName: "subjectC", status : "FAILED" }
]
},
{
username: "Jason",
subjects: [
{subjectName: "subjectA", status : "PASSED" },
{subjectName: "subjectB", status : "PASSED" },
{subjectName: "subjectC", status : "FAILED" }
]
}
我怎樣才能得到所有以下列格式傳遞的科目?
[{username: "John", subjectName: "subjectA", status : "PASSED"},
{username: "John", subjectName: "subjectB", status : "PASSED"},
{username: "Jason", subjectName: "subjectA", status : "PASSED"},
{username: "Jason", subjectName: "subjectB", status : "PASSED"}]
你想使用像Java一樣的編程語言或直接試圖查詢? –
@PrasadKharkar我正在使用JavaScript與Mongoose。 – Sawyer