my document structure is:
db={
"booking": [
{
"_id": "5a934e000102030405000000",
"cart": [
{
"_id": "5a934e000102030405000001",
"productId": "5934e00010203040500031",
"timeSlots": [
{
"_id": "5a934e00010203040500022",
"spots": 10
},
{
"_id": "5a934e00010203040540002",
"spots": 2
},
{
"_id": "5a934e00010203040505002",
"spots": 1
}
]
},
{
"_id": "9934e00010203040500r33",
"productId": "9934e00010203040500041",
"timeSlots": [
{
"_id": "5a934e0001020304340002",
"spots": 3
},
{
"_id": "5a934e000102030405672",
"spots": 8
},
]
}
]
}
]
}
for query I have:
- bookingId
- productId
- cartId
- timeSlotId
- if only booking id matched then the query will return booking object, not other nested elements.
- if only bookingId and cartId matched then the query will return booking and cart object, timeSlotes will be ignored from nested document.
- if bookingId cartId and timeSlotId all three matched then the query will return booking, cart, and associated timeslot