Search code examples
google-cloud-firestorefirebase-security

Firestore security rule MapDiff methods on nested object


I am curious how MapDiff methods work on nested object

for example addedKeys, for top level only object

{"a":1}.diff({}).addedKeys() == ["a"].toSet()

this is how it works

but what about nested object?

{"a":{"b":"1"},"c":"2"}.diff({}).addedKeys() == [????].toSet()

and is the behaviour same on affectedKeys, changedKeys, removedKeys and unchangedKeys?


Solution

  • ok, I use rules.debug and found the answer

    in the log, it prints

    set_value {
      values {
        string_value: "a"
      }
      values {
        string_value: "c"
      }
    }
    

    so basically {"a":{"b":"1"},"c":"2"}.diff({}).addedKeys() == ["a","c"].toSet()

    it ignores nested property