I have a firebase database in this structure:
{
"-L4Wqs3YbAlUgTWElF4Q" : {
"receita" : {
"-L6m_C46-Mj1py6RtF8H" : {
"imagem" : "default",
"ingrediente" : [ "ovo", "leite" ],
"nome" : "um nome",
"preparo" : "um preparo",
"tipo" : true
},
"-L6m_Finc29fAlqU0nqe" : {
"imagem" : "default",
"ingrediente" : [ "amendoim" ],
"nome" : "teste",
"preparo" : "teste",
"tipo" : false
}
},
"senha" : "123456789",
"usuario" : "guilherme"
},
"-L4WrImJ05VhzBgKHX6S" : {
"senha" : "123456789",
"usuario" : "patricia"
}
}
I have users and users have recipes, how do I get recipes from all users that type is true
?
My read function:
function ler() {
firebase.database().ref(referencia_database).orderByChild('nome').once('value').then(function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var chave = childSnapshot.key
var obj = childSnapshot.val()
var url
if(obj.imagem == './image/default.png')
url = './image/default.png'
else
url = 'https://firebasestorage.googleapis.com/v0/b/receitas-alpha.appspot.com/o/' + chave + '%2F' + obj.imagem + '?alt=media&token=c634d1db-dc4c-4cb9-8630-fbedff537237'
mostrar(chave, obj.nome, url)
})
})
}
referencia_database
is chave_usuario_logado + '/receita/'
I want to make this query by holding the sort order by name