unfornately i should insert record with parentid into realtime databse in firebase
this is my sample added record in chat collection that messageId and key of parent is same
"-N6w7t_jTLazBcbLnIau": {
"content": "Test message 1",
"fromId": "Yto2rkMyXJNVkWS3xAOJgUjXFzI3",
"messageId": "-N6w7t_jTLazBcbLnIau",
"phone": "+989034015019",
"timestamp": "1657792676492",
"toId": "0FXpksPdL4OAf9KAXx9B0R6nzmh2",
"type": "1"
},
"-N6w8651yjmhOKRHd5xG": {
"content": "Test massege 2",
"fromId": "Yto2rkMyXJNVkWS3xAOJgUjXFzI3",
"messageId": "-N6w8651yjmhOKRHd5xG",
"phone": "+989034015019",
"timestamp": "1657792676592",
"toId": "0FXpksPdL4OAf9KAXx9B0R6nzmh2",
"type": "1"
},
and this is my code in java script
firebaseDb.ref('chat/' + state.userDetails.userId ).push(payload.message)
but how i should get ky of my parent id or push key before insert??