I´ve sorted the table on this situation:
$("#Btn").click(
function() {
var ref = firebase.database().ref().child("songs").orderByChild("property").limitToFirst(5);
ref.on("child_added", snap => {
var song = snap.child("nameSong").val();
var artist = snap.child("nameBand").val();
var property = snap.child("property").val();
var idSong = snap.child("idSong").val();
$("#table_body").append("<tr><td>" + artist + "</td><td>" + song + "</td><td>" + property + "</td><td>" + idSong + "</td></tr>");
});
But I need to show only when a child is matched the variable fromGarito, like this:
$("#Btn").click(
function() {
var fromGarito;
var user = firebase.auth().currentUser;
if (user != null) {
fromGarito = user.uid;
}
var ref = firebase.database().ref().child("songs").child(fromGarito).orderByChild("property").limitToFirst(5);
ref.on("child_added", snap => {
var song = snap.child("nameSong").val();
var artist = snap.child("nameBand").val();
var property = snap.child("property").val();
var idSong = snap.child("idSong").val();
$("#table_body").append("<tr><td>" + artist + "</td><td>" + song + "</td><td>" + property + "</td><td>" + idSong + "</td></tr>");
});
Aucun commentaire:
Enregistrer un commentaire