Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8271979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:59:20+00:00 2026-06-08T06:59:20+00:00

Counting records in a table is obviously a manual effort until you guys get

  • 0

Counting records in a table is obviously a manual effort until you guys get some of that spiffy new functionality already in the works 😉

However, I’m stuck on even using a manual run with .on(‘value’, …) to fetch a count:

var table = new Firebase('http://beta.firebase.com/user/tablename');
var count = 0;
table.on('child_added', function(snapshot) {
   count++;
   // how do I know if this is the last child? i.e. the count is complete?
});

// when is it okay to use count?

I foresee the same issues with any sort of pagination and I feel like I’m being a bit blockheaded about this. What am I missing?

Is this fundamentally the wrong pattern for, say, getting the number of messages a user has in his/her queue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:59:22+00:00Added an answer on June 8, 2026 at 6:59 am

    With “child_added” there is no way to know when you’ve received the “last” item. If you’re looking to count all of the children that existed at a particular point in time, I’d suggest using the “value” event as follows:

    var table = new Firebase('http://beta.firebase.com/user/tablename');
    
    table.on('value', function(snapshot) {
       var count = 0;
       snapshot.forEach(function() {
           count++;
       });
       //count is now safe to use.
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL table that has 165,716 records (and counting). The table is
I'm counting the right answers field of a table and saving that calculated value
This is my simple query in mysql/zend: // Get Patients $table = new Model_Patient_DbTable();
How would I go about counting the characters after a certain character. I'm new
I'm trying to write a Counting sort function but for some reason it's getting
I have a table with records which include a datetime column CreationDate. I need
I have a mySQL table with records of users who have visited my site.
I'm new to PHP, so I need some guidance as to which would be
I have table with statistical data. I'm trying to count the records grouped by
I am trying to figure out how to display a count for records that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.