Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
153 views
in Technique[技术] by (71.8m points)

javascript - How to increment a record in Firebase?

I have a Firebase record "searches: 0" for each user. On some event, I'd like to add 1 to what the current count is. I've gotten this far, but for some reason, it's not working:

du.fbAddSearchCount = function() {
    var usr = new Firebase(firebase_url + "/users/" + user_uid);

    usr.on("value", function(snapshot) {
        user = snapshot.val();

       var usersRef = ref.child("users");

       var fbUser = usersRef.child(user_uid);
       fbUser.update( {
           searches: user.searches + 1
       });
    }
}

Any help to get this working?

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...