title: Maintain Unique Array In Mongo
body: <p>Below code represent that 101 has initiated chat with 102.</p>
  
  <pre><code>db.chat.insert(
     {
       "mydate" : ISODate(),
       "chatusers" : [101,102]
     }
  )
  </code></pre>
  
  <p>To make sure this entry is unique and there should be no duplicate like
  [101,102] or [102,101] is tried to add unique index in chatusers but this does not work on pairs as it dont allow to use either of 101 or 102.</p>
  
  <p>Question:
  One way is to make sure at application end or should i change my collection schema?
  What is the better approach and please suggest schema for the same.</p>
  
  <p>Note:
  select Queries will be based on both sender and receiver.</p>