I am struggling with a cloud function that updates the "presence" property on a collectionGroup "place_users".
My query does not filter the entries by "presence" == true. It used to work client-side, but I switched it to cloud-function and it no longer filters. All documents are returned.
exports.updatePoiPresence = functions.https.onCall((data: any, context: any) => {
return new Promise((resolve, reject) => {
return store.collectionGroup("place_users",
(ref: any) => ref
.where("user_id", "==", context.auth.uid)
.where("day_stamp", "<", data.start_of_day / 1000)
.where("presence", "==", true))
.get()
.then(
(q_snapshot: any) => {
return q_snapshot.forEach((snapshot: any) => {
functions.logger.log("no docs value data fct:", snapshot.data())
snapshot.ref.update({
presence: false
})
.then((a: any) => {
resolve("ok");
})
.catch((error: any) => {
functions.logger.log("error survenue", error);
reject("Rejet pas identifie")
})
});
})
});
});
I have a series of indexes created for that collectionGroup: (I have no idea which one are used in what situation since I have ve been clicking on the index creator wizard through the console without thinking about their purpose.