DEV Community

loading...

Discussion on: Restrict specific fields updation in Firebase Firestore

Collapse
hakimio profile image
Tomas Rimkus

You could simplify this by using "MapDiff":

function notUpdatingNested(fsmap, field) {
    return !(fsmap in request.resource.data) 
        || (
            (request.resource.data[fsmap] is map)
            && (fsmap in resource.data)
            && !(request.resource.data[fsmap].diff(resource.data[fsmap]).affectedKeys().hasAny([field]))
        )
}
Enter fullscreen mode Exit fullscreen mode
Forem Open with the Forem app