title: Build private chats in Firebase and Javascript
body: <p>I am building an app with Firebase that requires private messaging between users.
  What I need is to build single chats for 1-1 chats, storing messages in Firestore.</p>
  
  <p><strong>My idea:</strong> I guess the best way is to build a single collection for each chat, with the right security rules. Let's say an user with tokenID 1234 wants to talk with user with tokenID 1111, a new collection called 1234_1111 will be created (if not existing), and the security will allow only these two users to read and write.</p>
  
  <p><strong>My question:</strong> Is it the right way? And how to do that in Javascript? I'm not sure how to define security rules directly in the JS code, neither how to create a collection with the two users ID.  </p>