Hi there,
I have the following document format:
"_id":"R8RtHVE_s6nt",
"username":"fakeuser",
"email":"fake@user.me",
"password":"$2a$10$U9UxCmih5CN9PV/fSeL/fux4vXIkKDJF.rIC90wfg8Xmyu.K3pnA2",
"name":"Fake User",
"phone_number":"07901 234 567",
"agency_logo":null,
"email_verified":true,
"is_private":"true",
"user_type":"Trial User",
"properties":[
{
"_id":"15HpnDNaKduf",
"creator_id":"R8RtHVE_s6nt",
"cover_photo":null,
"email":"fake@user.me",
"address_line_one":"117 MountShame Avevue",
"address_line_two":"York Road",
"city":"North Hampton",
"post_code":"NH98 8SH",
"lease_length":"12 months",
"rental_price":"600",
"security_deposit":"600",
"createdAt":{
"$date":"2021-11-19T08:42:56.162Z"
},
"updatedAt":{
"$date":"2021-11-19T08:42:56.162Z"
},
"applications":{
"pv":[
{
"_id":"NmvBdS",
"typeform_id":"tAJNouzG",
"status":"Pending",
"tenant_email":"fake@tenant.me",
"tenant_fullname":"Fake Tenant",
"answers":[
{
"type":"text",
"text":"Fake",
"field":{
"id":"ZD3IzPGTuS40",
"type":"short_text",
"ref":"8ef37986-ba96-47ed-a085-05a82d5691b4"
}
},
{
"type":"text",
"text":"Tenant",
"field":{
"id":"aJyKzC3GppTU",
"type":"short_text",
"ref":"769ab1d6-939c-4be1-bf38-4d10cd9c1de0"
}
},
{
"type":"email",
"email":"fake@tenant.me",
"field":{
"id":"WbceTNPHArq3",
"type":"email",
"ref":"af4c02d238559bc8"
}
}
],
"key_values":{
"What is your First Name?":"Fake",
"What is your Last Name?":"Tenant",
"What's your Email Address?":"fake@tenant.me"
},
"property_id":"15HpnDNaKduf",
"submitted_at":1637311603000,
"notes":""
}
]
}
}
],
"createdAt":1637311288461,
"notifications":[
{
"_id":"3yLs",
"status":"success",
"form_type":"pv",
"title":"🏠 New Pre-Viewing Application",
"desc":"You've received a new Pre-Viewing Application from Fake Tenant.",
"typeform_id":"tAJNouzG",
"property_id":"15HpnDNaKduf",
"created_at":1637311603000
}
]
I am trying to find an Application (applications/pv) in the applications array (which can have multiple different type, pv, lt, jt) by ID.
So I’m actually trying to aggregate over the users array by ID, the properties array by ID and finally the applications array by ID → then, return that object.
Can anyone please help?