I have an object array which have query string. I loop through the query based on key. Query is working as expected. But the key value is not printing inside
query = {
A: { code: { '$in': ['A'] }},
B: { code: { '$in': ['B'] }}
}
for (keyQuery of Object.keys(query)) {
console.log("outside",keyQuery );
testcollection
.find(query[keyQuery],{_id:0})
.then(data => {
console.log("inside",keyQuery);
});
}
Current Output is
outside A
outside B
inside B
inside B
Expected Output is
outside A
outside B
inside A
inside B
What mistake I am doing