I have the below data structure for the members
property in my teams
collection.
and I am trying to write the below query via triggers to update the structure whenever there is an update on the members
collection.
const teamData = await firebaseAdmin
.firestore()
.collection('teams')
.where('members', 'array-contains', { id: change.after.id })
.get();
But this always returns an empty set of collections even though the data matches. I referred this post and then tried as below wherein I had compared complete object with the data available in the before context. But again even that would return the empty result set.
const memberBefore = change.before.data() as Member;
const teamData = await firebaseAdmin
.firestore()
.collection('teams')
.where('members', 'array-contains', [
{
id: change.after.id,
name: memberBefore.name,
nameKa: memberBefore.nameKa,
img: memberBefore.img,
},
])
.get();
Could someone help me out to resolve this issue?