You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This template shows how to keep track of the number of elements in a Firebase Database list. This can be useful to keep tack of the number of "likes" or "followers" of a somethings shares through social media.
3
+
This template shows how to keep track of the number of elements in a Firebase Database list. For instance this can be useful to keep tack of the number of "likes" or "followers" of something shared on a social platform.
4
4
5
-
## Cloud Function Code
5
+
## Functions Code
6
6
7
-
See file [index.js](index.js) for the code.
7
+
See file [index.js](functions/index.js) for the code.
8
8
9
9
This is done by simply updating a `likes_count` attribute on the parent of the list node which is tracked.
10
10
11
11
The dependencies are listed in [package.json](package.json).
12
12
13
13
## Sample Database Structure
14
14
15
-
As an example we'll be using the database structure shown below. It keeps tracks of the list of users who liked an image and the count of these likes:
15
+
As an example we'll be using the database structure shown below. It keeps tracks of the list of users who liked a post and the count of these likes:
16
16
17
17
```
18
18
/functions-project-12345
19
-
/images
19
+
/posts
20
20
/key-123456
21
21
likes_count: 32
22
22
/likes
@@ -25,22 +25,3 @@ As an example we'll be using the database structure shown below. It keeps tracks
25
25
user786245: true
26
26
...
27
27
```
28
-
29
-
## Trigger rules
30
-
31
-
Below is the trigger rule for the `countlikes` function making sure it's triggered when a new like is added/removed.
0 commit comments