abrahamlinkedin abrahamlinkedin - 10 months ago 67
Javascript Question

Storing arrays with Firebase

In Firebase I have the function

which is meant to submit data
Do the dishes
to an array named
. However, I do not know how to get the push method to send to an array. My code is below.

var self = this;
var user = firebase.auth().currentUser;
var getUserInfo = firebase.database().ref('users/' + user.uid);

if (user){
addnote: ["Do the dishes"]

My push method winds up giving me several
arrays instead of placing all strings of
Do the dishes
in the same one. So it looks like:

addnote - 'Do the dishes'
addnote - 'Do the dishes'

As opposed to:

addnote - 'Do the dishes', 'Do the dishes'

How would I reorganize my code to make this work?

Answer Source

I think you're looking for:

getUserInfo.child("addnote").push("Do the dishes");