Advertisement
karamarimo

Untitled

Nov 12th, 2017
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.22 KB | None | 0 0
  1. "userStar":{  
  2.    ".validate":"newData.hasChild('starCount')",
  3.    "stars":{  
  4.       "$starUid":{  
  5.          ".write":"auth.uid == $starUid &&
  6.                   (!data.exists() && newData.exists() &&
  7.                   newData.parent().parent().child('starCount').val() == data.parent().parent().child('starCount').val() + 1
  8.                    ) ||
  9.                   (data.exists() && !newData.exists() &&
  10.                   newData.parent().parent().child('starCount').val() == data.parent().parent().child('starCount').val() - 1
  11.                    )",
  12.         ".validate": "newData.val() == true"
  13.       }
  14.  
  15.    },
  16.    "starCount":{
  17.       ".write":"auth != null && newData.isNumber()",
  18.       ".validate":"(newData.val() == data.val() + 1 &&  
  19.                   newData.parent().child('stars').child(auth.uid).val() == true &&  
  20.                   !data.parent().child('stars').child(auth.uid).exists()
  21.                  ) ||
  22.                  (newData.val() == data.val() - 1 &&  
  23.                   !newData.parent().child('stars').child(auth.uid).exists() &&  
  24.                   data.parent().child('stars').child(auth.uid).val() == true
  25.                  )"
  26.    },
  27.    "$others":{
  28.       ".validate":false
  29.    }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement