DEV Community

Discussion on: Restrict specific fields updation in Firebase Firestore

Collapse
 
richard_sylvest profile image
Richard Sylvester

Good article Kushagra, only one small problem. If you run your code in the firestore rule playground it will fail for fields that cannot be updated but don't exist in the document yet. The following will fix that:

function notUpdating(field) 
{
    return !(field in request.resource.data) || (field in resource.data && resource.data[field] == request.resource.data[field]);
}