My MongoDB stores documents having the following structure:
{
"application_detail":{},
"curl_detail":{
"Curl1":{
"key1":"value1",
"key2":"value2"
},
"Curl2":{
"key1":"value1",
"key2":"value2"
},
"Curl3":{
"key1":"value1",
"key2":"value2"
},
"Curl4":{
"key1":"value1",
"key2":"value2"
},
/*total number of curls are unknown*/
}
}
How can I fetch key1 for all the curls present under curl_detail from mongoDB using express and mongoose?
Expected Output:
{
"curl_detail": {
"Curl1": {
"key1": "value1"
},
"Curl2": {
"key1": "value1"
},
"Curl3": {
"key1": "value1"
},
"Curl4": {
"key1": "value1"
}
}
}
NOTE: Total number of curls are unknown.
{ "curl_detail":{ "Curl1":{ "key1":"value1" }, "Curl2":{ "key1":"value1" }, "Curl3":{ "key1":"value1" }, "Curl4":{ "key1":"value1" } /* so on for all the curls present in that document */ } }@AnkitaKuchhadiya This is the output I expect."curl_detail": { "Curl1": "value1", "Curl2": "value1", "Curl3": "value1", "Curl4": "value1" }