Firebase rules for increment operation not working -


i have simple firebase database, single entry "async-testing/companies: 0". enter image description here

i have following firebase rules, meant set "companies" 0 if undefined, , otherwise allow write if greater current value of "companies" 1:

{   "rules": {       ".read": "auth != null",       ".write": "auth != null",       "async-testing": {         "companies": {                 ".validate": "(data.exists() && (newdata.val() === data.val() + 1)) || (!data.exists() && newdata.val() == 0)"          }       }   } } 

however, when attempt set "companies" equal 1 in firebase simulator, not work:

enter image description here

even stranger, when set firebase rules accept write if "companies" undefined, works correctly:

{   "rules": {       ".read": "auth != null",       ".write": "auth != null",       "async-testing": {         "companies": {                 ".validate": "!data.exists()"          }       }   } } 

any appreciated. thanks.

the 'async-testing' layer not required. try:

{   "rules": {       ".read": "auth != null",       ".write": "auth != null",         "companies": {                 ".validate": "(data.exists() && (newdata.val() === data.val() + 1)) || (!data.exists() && newdata.val() == 0)"          }   } } 

enter image description here


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -