title: mongodb - Find count of values in other collection
body: <p>I want to find how many "taskId" of below collectionOne is present in collectionTwo.
  Here, "taskId" in below collectionOne is embedded inside a array in a document.</p>
  
  <p>Also, Let me know the different approaches to do this (if possible). </p>
  
  <pre><code>db.collectionOne.find({"sId":"DCNrnPeKFrBv" }).pretty()
  {
          "_id" : "sX8o7mJhebs",
          "sId" : "DCNrnPeKFrBv",
          "data" : [
                  {
                          "oId" : "7SycYQ",
                          "taskId" : 146108906
                  },
                  {
                          "oId" : "7SycYQ",
                          "taskId" : 14623846
                  },
                  {
                          "oId" : "fANQ",
                          "taskId" : 1461982
                  },
                  {
                          "oId" : "fAeNQ",
                          "taskId" : 131732
                  },
                  {
                          "oId" : "t6AF5yn",
                          "taskId" : 197681
                  }
          ]
  }
  
  
  
  &gt; db.collectionTwo.find().pretty().limit(2)
  {
          "_id" : 146108906,
          "oId" : "7SycYQ",
          "name" : "ABC"
  }
  {
          "_id" : 1461982,
          "oId" : "fANQ",
          "name" : "XYZ"
  }
  </code></pre>
  
  <p>In collectionTwo "_id" is equivalent to  "taskId" of collectionOne.</p>