1
Assuming I have this structure in the bank
userId : {
Messages : {
SenderID : {
PushID: {
"msg": "Mensagem"
}
}
}
I’m using this code to "read" everything inside the "userid"
dbRef.child(user.uid + "/Messages").on("value", function(snap){
obj.html(JSON.stringify(snap.val(), null, 3));
});
but the return I need is just the "msg": "message"
would like to know how to return only what I need, can anyone help me ? From now on
What is the context? Do you want that specific message or all the messages from
UserId
?– Costamilam
Good evening Guilherme, All messages within Senderid. that part of the bank would be a chat between two users
– Osvaldo Pereira
I believe I should review the structure of the bank, personally I would change its structure, it is recommended to avoid the use of many chained nodes
– Costamilam
Can you give me an idea of structure ?
– Osvaldo Pereira
In itself documentation an example chat is used to explain how to structure the database. I would transform Senderid and Userid into two Pushid fields
– Costamilam
Perfect my friend , I took a look at the link of the documentation you sent there , and solved , I will change the structure and the way to store the msgs , honestly this way I was trying to do would have to replicate a lot of data , and with this idea there of the documentation I store everything in a single place where only the two users can read , thanks friend
– Osvaldo Pereira
If you have any difficulty in doing something edit the question with your question and let us know in the comments :)
– Costamilam