Loading...
46 | 47 | 48 | By | 49 | Updated at | 50 | 0 Views 51 | 52 | 53 |54 | 55 | 56 | 57 |
58 |
├── README.md ├── profile.html ├── login.html ├── index.html ├── create.html ├── entry.html └── update.html /README.md: -------------------------------------------------------------------------------- 1 | ## Live Demo 2 | 3 | https://earthchie.github.io/Firebase-CRUD-Example/ 4 | 5 | http://earthchie.com/firebase/crud/ (Thai language interface) 6 | 7 | #### Rules 8 | ```json 9 | { 10 | "rules": { 11 | ".read": true, 12 | ".write": "auth != null", 13 | 14 | "Entry": { 15 | ".read": true, 16 | ".write": "auth != null", 17 | 18 | "$child": { 19 | ".read": true, 20 | ".write": "auth != null", 21 | 22 | "views": { 23 | ".read": true, 24 | ".write": true, 25 | ".validate": "data.val() == null || newData.val() == data.val() || newData.val() == data.val()+1" 26 | } 27 | } 28 | } 29 | } 30 | } 31 | ``` 32 | This rule allows guest to increase number of views, while protect them from editing something else. 33 | 34 | Let's break down this line 35 | ```json 36 | ".validate": "data.val() == null || newData.val() == data.val() || newData.val() == data.val()+1" 37 | ``` 38 | 39 | ``data.val() == null`` is allow to create. 40 | 41 | ``newData.val() == data.val()`` is allow to update with the exact same value. 42 | 43 | ``newData.val() == data.val()+1`` is allow to increase value by 1. 44 | 45 | ## License 46 | WTFPL 2.0 http://www.wtfpl.net/ 47 | -------------------------------------------------------------------------------- /profile.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |