I'm storing newsletter subscriber emails in the firebase database in this way:
I'm trying to write a firebase rule to allow the writing only if there's no the same email in the db.
this is the emails data structure:
emails: {
id1: {
email:"banana@gmail.com"
},
id2: {
email:"watermelon@gmail.com"
}
}
and this is my firebase rule for emails:
match /emails/{document=**} {
allow read: if request.auth != null
allow write: if request.resource.data.email != ???
}
How can i check if each id*.email
is different from the query one?
I've already checked similar questions on StackOverflow but the answers are not very clear to me.
Thank you!