angularjs - How can I query in firebase using angularFire? -
angularjs - How can I query in firebase using angularFire? -
i have simple construction in firebase:
{ "categorias" : { "categoria2" : { "subcategorias" : { "subcategoria4" : { "nome" : "subcategoria 4" }, "subcategoria6" : { "nome" : "subcategoria 6" }, "subcategoria5" : { "nome" : "subcategoria 5" } }, "icone" : "fa-cloud", "nome" : "categoria 2" }, "categoria1" : { "subcategorias" : { "subcategoria1" : { "nome" : "subcategoria 1" }, "subcategoria3" : { "nome" : "subcategoria 3" }, "subcategoria2" : { "nome" : "subcategoria 2" } }, "icone" : "fa-bolt", "nome" : "categoria 1" } }, "locais" : { "local1" : { "subcategorias" : { "subcategoria4" : true, "subcategoria1" : true }, "nome" : "local 1", "email" : "local1@loc1.com" } } }
i need list "locais" have "subcateria1: true" example. don't know how because need "localid" in query don't know localid. want "locais" belongs subcategoria1.
i'm using angularfire.
i find solution, don't know if right way:
findbysubcategoria: function(subcategoriaid) { var result = {}; locais.$on("value", function(snap){ var keys = snap.snapshot.value; angular.foreach(keys, function(key, i){ if(key.subcategorias[subcategoriaid]){ result[i] = locais.$child(i); } }); }); homecoming result; }
angularjs nosql firebase angularfire
Comments
Post a Comment