abrahamlinkedin abrahamlinkedin - 2 months ago 16
Javascript Question

Storing arrays with Firebase

In Firebase I have the function

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

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

if (user){
getUserInfo.push({
addnote: ["Do the dishes"]
});
}
}


My push method winds up giving me several
addnote
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

I think you're looking for:

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