title: How do I arrange my data in Firestore to avoid performance issues when users increase
body: <p>I have 2 Firestore collections I am worried about. Named <strong>Posts</strong> and <strong>Chats</strong>.</p>
  <p><strong>POSTS</strong></p>
  <p><em><strong>The setup</strong></em> -- In Posts, each document has a field named <strong>Comments</strong> (an array of objects). Every time a comment is made on a Post document, the comment obj is added to Comments array, and every time a comment is updated, the comments array is overridden with new set of comments that include the updated comment object.</p>
  <p><em><strong>The issue</strong></em> -- Firestore docs warn against updating documents more than once per second to avoid contention and other errors (which I have witnessed in the Chats collection). How do I avoid this problem? As post comments are expected to update very frequently.</p>
  <p><strong>CHATS</strong></p>
  <p><em><strong>The setup</strong></em> -- In Chats, each document has a field named <strong>Mesages</strong> (array of objects) and each object has a property named <strong>received</strong>. Messages field works very similar to Comments field. Also in each document is a field named <strong>UsersTyping</strong> (array of userId strings) which updates every time a users text input changes from empty to not empty and vice versa.</p>
  <p><em><strong>The Issue</strong></em> -- Just like Posts, updates to a document should not happen more than once per second. But because of app requirements, updates to <em><strong>userTyping</strong></em> and <em><strong>message.received</strong></em> need to take place, meaning a lot of updates to the document could happen within a second. How do I avoid this problem?</p>
  <p><strong>Tech Stack</strong> == React Native, Expo managed workflow, Firebase,</p>
  <p>Thank you in advance for your suggestions. </p>