title: How to insert new child data in Firebase web app?
body: <p>I am building a simple car database app. When a user adds a new car it creates the below JSON data with blank fields for the gallery:</p>
  
  <pre><code>{
      "name": "Cars",
      "gallery": [{
          "img": "http://",
          "title": "BMW"
      }, {
          "img": "http://",
          "title": "Lexus"
      }, {
          "img": "http://",
          "title": "Ferrari"
      }],
      "pageId": "23",
      "storeURL": "/app/cars/gallery"
  }
  </code></pre>
  
  <p>Now what I want to do in the app is if a user adds a new gallery image it should add new child after the last gallery picture. So after <strong>Ferrari</strong> it should insert a new object. I cannot seem to do this as every tutorial leads to a dead end and also the official Google docs specify that <code>set()</code> will replace all data so if you use <code>update()</code> it will add and in this case it does not add.</p>
  
  <p>This code deletes all data:</p>
  
  <pre><code>function add(){
    var data = [
      {
        title: 'Mercedes',
        img: 'http://'
      }
    ]
    var postData = {
      pageGallery: data
    };
    var updates = {};
    updates['/app/cars/'] = postData;
    firebase.database().ref().update(updates);
    console.log('New car added');
  
  }
  </code></pre>
  
  <p>And if I change and add the child:</p>
  
  <pre><code>firebase.database().ref().child('gallery').update(updates);
  </code></pre>
  
  <p>It does not do anything to do the data. Please can you help?</p>