Search code examples
firebasefirebase-realtime-databasefirebase-security

Understanding (root) in firebase security rules


From what I understand root.child(...) in firebase security rules represents the old data at the child.

Lets say multiple users A,B,C,D updated the same child node together.

Server gets them likes this:

  1. A first.
  2. B next.
  3. C next.
  4. D next.

My Question:

When B is processed. Shouldn't root hold the data that was updated by A ?


Solution

  • If you send these as a single write operation, they are processed atomically so they are either all applied in one go or none of them are applied. The root will not be updated until they are all applied, so only for the next write operation you send.

    If you require an explicit ordering of the write operation, send them as separate write operations to the database.