I have a collection with documents that follow the following model:
{
"cardId": "12345678900",
"phone": "123456789",
"name": "Scott",
"services": [
{
"name": "Estudios 3D para vías aéreas"
},
{
"name": "Estudios 3D para ortodoncia"
},
{
"name": "Estudios 3D para senos paranasales",
"doctorId": "ASNDUasd981239nasd"
},
{
"name": "Estudios 3D para implantes dentales",
"pdfUrl": [],
"imgUrl": [],
"doctorId": 1
},
{
"name": "Estudios 3D para vías aéreas",
"imgUrl": [
"https://firebasestorage.googleapis.com/v0/b/cid-imagenes.appspot.com/o/patients%2Fimages%2Frc-upload-1678379057443-9?alt=media&token=b156f890-aa2a-49e8-aa73-52260124b279"
],
"pdfUrl": [
"https://firebasestorage.googleapis.com/v0/b/cid-imagenes.appspot.com/o/patients%2Fdocuments%2Frc-upload-1678379057443-11?alt=media&token=c61378ba-413b-4e89-ba57-3a93e9f66a3f"
]
}
],
"lastname": "Castro",
"birthdate": "Thu Mar 02 2023 15:43:23 GMT-0400 (hora estándar del Atlántico)",
"gender": "M",
"imgUrl": "",
"type": "PATIENT",
"email": "[email protected]",
"referredById": 1
}
How can I get all the documents of that collection where at least one object inside the “services” array contains a doctorId property with the value of 1, the firebase library in react.
I tried using the method:
query(ref, where('services', 'array-contains-any', { doctorId: 1 }));
But it doesn’t work, because apart from the doctorId property, the object inside the “services” array has other properties, so it doesn’t match