i have this database:
users: get(ref(db, `users/${db_uname}/game`)).then((snapshot) => {
000: if (!(snapshot.exists())) {
game: set(ref(db, `users/${db_uname}/game`), {
cord_x: 0 cord_x: 0,
cord_y: 0 cord_y: 0
online: true });
password: "000" }
update(ref(db, `users/${db_uname}/game`), {
online: true
});
var con = true;
window.db_con = con;
});
And i need to get username, game/cord_x, game/cord_y
from all users with game/online == true, to call a function with them later. Please help! 🙁
function getUsers() {
get(child(db, `users/`)).then((snapshot) => {
(( DONT KNOW HOW ))
create_hero(name, x, y);
})
});
}
2
Answers
Based on Frank van Puffelen's answer i made what i needed, if someone ever needs needs it, here it is:
To get the db_uname, cord_x and cord_y for all nodes from your data structure, you can do: