├── 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 | Firebase - Profile 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 |
23 |
24 | 43 | 44 |

Firebase - Profile

45 | 46 | 47 |
48 |
49 | 50 |

51 | 
52 |     
53 | 54 | 55 | 56 | 57 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Firebase - Login 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 |
23 |
24 | 43 | 44 |

Firebase - Login

45 | 46 |
47 | 48 |
49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Firebase - List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 |
23 |
24 | 43 | 44 |

Firebase - List

45 | 46 |
47 | 48 |
49 | 50 |
51 | 52 | 53 | 54 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /create.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Firebase - Create 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 |
23 |
24 | 43 | 44 |
45 |

Title

46 |
47 | 48 | 49 |
50 |
51 | 52 |

Content

53 |
54 | 55 | 56 |
57 |
58 | 59 |
60 | 61 |
62 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /entry.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Firebase - Entry 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 |
23 |
24 | 43 | 44 |
45 |

Loading...

46 | 47 | 48 | By | 49 | Updated at | 50 | 0 Views 51 | 52 | 53 |
54 | 55 |
56 | 57 |
58 |
59 | 60 |   61 |   62 |   63 |   64 | Update 65 |
66 | 67 |
68 | 69 |
70 | 71 | 72 | 73 | 74 | 75 | 76 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /update.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Firebase - Update 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 |
23 |
24 | 43 | 44 |
45 |

Title

46 |
47 | 48 | 49 |
50 |
51 | 52 |

Content

53 |
54 | 55 | 56 |
57 |
58 | 59 |
60 | 61 |
62 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 170 | 171 | 172 | 173 | 174 | 175 | --------------------------------------------------------------------------------