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

  • Home
  • SEARCH
  • 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 9084403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:59:23+00:00 2026-06-16T20:59:23+00:00

I have the following code: var myRootRef = new Firebase(‘https://myacct.firebaseIO.com’); var collectionRef = myRootRef.child(‘collection’);

  • 0

I have the following code:

var myRootRef = new Firebase('https://myacct.firebaseIO.com');
var collectionRef = myRootRef.child('collection');
var pushRef = collectionRef.push();

pushRef.set('item1');
pushRef.set('item2');
pushRef.set('item3');

If I go to the url: ‘https://myacct.firebaseIO.com’, I see only ‘item3’ in collection. I do not see the other two. It appears that the collection object is being rewritten rather than being added to. If I manually type out the child names, things work. For example, the following works:

collectionRef.child(1).set('item1');
collectionRef.child(2).set('item2');
collectionRef.child(3).set('item3');

Is this a bug, or am I doing something wrong in the way I am using push?

Thanks.

  • 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-16T20:59:25+00:00Added an answer on June 16, 2026 at 8:59 pm

    The code you’ve written is working as expected. push() is a helper that creates a reference to a new child with a unique name, and it’s a good way to create a list of items in Firebase.

    Your code could be rewritten as follows:

    var myRootRef = new Firebase('https://myacct.firebaseIO.com');
    var collectionRef = myRootRef.child('collection');
    
    collectionRef.push().set('item1');
    collectionRef.push().set('item2');
    collectionRef.push().set('item3');
    

    push() can optionally take an argument that will be set as the value at the new reference. You can therefore shorten your code a bit like this:

    collectionRef.push('item1');
    collectionRef.push('item2');
    collectionRef.push('item3');
    

    You can read more about working with push() here:
    https://www.firebase.com/docs/managing-lists.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: var json = new WebClient().DownloadString(string.Format(@http://www.google.com/dictionary/json?callback=dict_api.callbacks.id100&q={0}&sl=en&tl=en, bar)); This returns something
I have the following code: var carsContext = new CarsDataContext(); IQueryable<Car> allCars = carsContext.Cars;
I have the following code: var tlp = new TableLayoutPanel { Location = new
I have the following code: var service = new Mock<INavigationService>(); service.Setup(x => x.GetSchemes(new SchemeFilterEntity())).Returns(new
I have the following code: var psi = new ProcessStartInfo(); psi.FileName = @C:\gw\gw.exe; psi.WorkingDirectory=@C:\gw;
I have the following code: var intrebari = new Array(); var i = 0;
I have the following code: var commitmentItems = new List<CommitmentItem<ITransaction>>(); commitmentItems.Add(new CapitalCallCommitmentItem()); And I
I have the following code: var numberOfSelectedOptions = new Array(); numberOfSelectedOptions[0]=0; numberOfSelectedOptions[1]=0; numberOfSelectedOptions[2]=0; $(a.tagvariantoption).live(click,
I have the following code: var words = new Object(); $(li.words).each(function(){ var thisId =
I have the following code var section = new CustomConfigurationSection(); section.SectionInformation.Type = System.Configuration.NameValueFileSectionHandler; section.SectionInformation.SetRawXml(sectionXml);

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.