javascript - Firebase return a collection as an array -


i trying build app using firebase end , need seems simple problem. want return list of nested data (i know shouldn't nesting data!) array. try , solve have following give me collection of status each record in database:

    var ref = new firebase("https://firebase_url"); ref.orderbychild("status").on("child_added", function (snapshot) {     var articleid = snapshot.key();     var articledata = snapshot.val();     console.log(articledata.status.status); 

this gives me collection of status how combine these console.log list array?

you can declare array outside scope of firebase event, , on event push it:

var ref = new firebase("https://firebase_url"); var statuscollection = []; //array outside 'child_added' scope ref.orderbychild("status").on("child_added", function (snapshot) {     var articleid = snapshot.key();     var articledata = snapshot.val();     statuscollection.push(articledata.status.status);     //console shows full array collection     console.log(statuscollection) }); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -