push and array of objects to firebase 1

push and array of objects to firebase

var key1 = postsRef.push().key;
var key2 = postsRef.push().key;
var updates = {};
updates[key1] = {
      author: "gracehop1",
      title: "Announcing COBOL, a New Programming Language"
    };
updates[key2] = {
      author: "gracehop2",
      title: "Announcing COBOL, a New Programming Language"
    };
ref.update(updates);

Here is what the above code is Doing:
1. Create a new post reference with a generated key.
2. Create a new post reference with a generated key.
3. Create a new object containing the new post data, and use the newPostKey as the key.
4. Use update() to update the post data simultaneously in two locations.

Similar Posts