I have a member collection with following data:
db.member.insert(
{
userName: "TanNM",
password: "xxx",
wantList: [{
title: "Want 1.1 - HN",
description: "Want 1.1 description",
province:{
name: "Ha Noi",
districtList:[ { name: "Ha Dong", qty: 25 }, { name: "Ba Dinh", qty: 50 } , { name: "Cau Giay", qty: 25 }, { name: "Hoan Kiem", qty: 50 } ]
}
}, {
title: "Want 1.2 - HN",
description: "Want 1.2 description",
province:{
name: "SG",
districtList:[ { name: "Ha Dong", qty: 25 }, { name: "Ba Dinh", qty: 50 } , { name: "Cau Giay", qty: 25 }, { name: "Hoan Kiem", qty: 50 } ]
}
}],
stock: [ { size: "S", qty: 25 }, { size: "M", qty: 50 } ],
category: "clothing"
})
db.member.insert(
{
userName: "MinhNN",
password: "xxx",
wantList: [{
title: "Want 2.1 - HN",
description: "Want 2.1 description",
province:{
name: "Ha Noi",
districtList:[ { name: "Ha Dong", qty: 25 }, { name: "Ba Dinh", qty: 50 } , { name: "Cau Giay", qty: 25 }, { name: "Hoan Kiem", qty: 50 } ]
}
}, {title: "Want 2.2 - HN",
description: "Want 2.2 description",
province:{
name: "Ha Noi",
districtList:[ { name: "Ha Dong", qty: 25 }, { name: "Ba Dinh", qty: 50 } , { name: "Cau Giay", qty: 25 }, { name: "Hoan Kiem", qty: 50 } ]
}
}],
stock: [ { size: "S", qty: 25 }, { size: "M", qty: 50 } ],
category: "clothing"
})
db.member.insert(
{
userName: "DungNP",
password: "xxx",
wantList: {
title: "Want 3 - SG",
description: "Want 3 description",
province:{
name: "TP Ho Chi Minh",
districtList:[ { name: "Ha Dong", qty: 25 }, { name: "Ba Dinh", qty: 50 } , { name: "Cau Giay", qty: 25 }, { name: "Hoan Kiem", qty: 50 } ]
}
},
stock: [ { size: "S", qty: 25 }, { size: "M", qty: 50 } ],
category: "clothing"
})
Member have some Want (wantList), Want in a province/district.
How to get all "want" (Not all document) of all member with province.name is "Ha Noi"