Skip to content

Commit 15ea329

Browse files
author
katowulf
authored
More es6 cleanup (var to const)
1 parent 380fd08 commit 15ea329

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

child-count/functions/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ admin.initializeApp(functions.config().firebase);
2121

2222
// Keeps track of the length of the 'likes' child list in a separate property.
2323
exports.countlikechange = functions.database.ref('/posts/{postid}/likes/{likeid}').onWrite(event => {
24-
var collectionRef = event.data.ref.parent;
25-
var countRef = collectionRef.parent.child('likes_count');
24+
const collectionRef = event.data.ref.parent;
25+
const countRef = collectionRef.parent.child('likes_count');
2626

2727
// return the promise from .transaction() so our function
2828
// waits for this async event to complete before it exits
@@ -39,8 +39,9 @@ exports.countlikechange = functions.database.ref('/posts/{postid}/likes/{likeid}
3939
// If the number of likes gets deleted, recount the number of likes
4040
exports.recountlikes = functions.database.ref('/posts/{postid}/likes_count').onWrite(event => {
4141
if (!event.data.exists()) {
42-
var counterRef = event.data.ref;
43-
var collectionRef = counterRef.parent.child('likes');
42+
const counterRef = event.data.ref;
43+
const collectionRef = counterRef.parent.child('likes');
44+
4445
// return the promise from counterRef.set() so our function
4546
// waits for this async event to complete before it exits
4647
return collectionRef.once('value')

0 commit comments

Comments
 (0)