Firestore security rules for objects inside of the array
Hi everyone!
In my Firestore, I have a collection called "items" and there are couple of documents inside. Some of these documents have "reviews" property, which is created by
arrayUnion()
called from my front-end and the objects inside of this array always have 4 properties, one of them is userId
.
In my front-end, I'm sending a get request to get the whole reviews array, like this: doc.data().reviews
.
How can I write my security rules so that userId
is never returned no matter what?
I asked ChatGPT to help me write the rules, but these doesn't work:
And my query looks like this (Typescript):
2 Replies
Still haven't figured it out... ChatGPT says that it would be better for me to create a separate collection for reviews and somehow connect it together, but I feel that there might be more elegant solution.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View