title: How to structure chat with firebase
body: <p>I'm using Cloud Firestore (NoSQL) to store profile information for users like:</p>
  
  <pre><code>{
    "uid": "abc123",
    "name": "...",
    "friends": [
      "uid": "x234", 
    ]
    ...
  }
  </code></pre>
  
  <p>Now I'm wondering how to structure a direct chat from user to user. I'm thinking of either:</p>
  
  <p>Adding an addional field for each user document like:</p>
  
  <pre><code>"chats": [
   {
      "from": "name",
      "message": "...",
      ...
   },
    ...
  ]
  </code></pre>
  
  <p>Or instead of using Firestore for the chat, I consider using Firebase realtime database with a similar structure. </p>
  
  <p>The last approach would have the benefit, that the user-document would not be "bloated" with lots of chat protocols.</p>
  
  <p>I'd need some advice which would structure/implemention would suit this usecase best.</p>