i want to read messagea from realtime database in firebase with vue or javascript in quasar framework
my collection name in db is messages that have this strtucture: ******************************************* my db structure*******
messages
-N4zbIt0Ey6Bix54f5SE
content: "Hi"
fromId: "nTTcnND2y6OHUBVO2GxHoBFwQf32"
timestamp: 1655703420767
toId: "0FXpksPdL4OAf9KAXx9B0R6nzmh2"
type: 1
-N4zbIt0Ey6Bix54f5SE
content: "Hi,HOW ARE YOU"
fromId: "0FXpksPdL4OAf9KAXx9B0R6nzmh2"
timestamp: 1655703448111
toId: "nTTcnND2y6OHUBVO2GxHoBFwQf32"
type: 1
do you know how i query firebase to getmessages?? ithis is for save in state with Vuex
firebaseGetMessages({ commit, state }, otherUserId) {
let userId = state.userDetails.userId
messagesRef = firebaseDb.ref('messages/' + fromId + '/' + toId)
messagesRef.on('child_added', snapshot => {
let messageDetails = snapshot.val()
let messageId = snapshot.key
commit('addMessage', {
messageId,
messageDetails
})
})
i think this code is wrong please help me if you have any experince with firebase
i am not familar with realtime-databse and query in fcm but familar with mongodb and sql server database i think that firebase has some function to read message!!! is it n't???