I'm working on a simple group chat app. The realtime chatting will be done through Firebase Realtime Database and then after a while the messages will be moved to Firestore.
This is the structure I'm thinking of for RTDB. The groupID will be the first node after the root DB node. The next child under the groupID node will be the message that each user sends. This node will contain the createdate, the actual message, the user's uid, and the user's username.
However, I'm not sure how to generate a unique key in the place of MessageKey and MessageKey2 below. How do I generate something unique to insert in there?
Note: I tried getting the key from database.push() but it gave me this: https://APPNAME-cf4da.firebaseio.com/-M_hwyb15XnNDjGDaO7X
Would I just need to strip off that root node to use this as MessageKey?

push(). If you're having trouble with that, edit your question to show a minimal, complete snippet that reproduces where you got stuck. Right now there's simply not enough information for us to effectively help better than the linked docs (or this codelab) do. - Frank van Puffelen