title: mongodb query to find mutual likes to output count and profiles
body: <p>I have two collections:</p>
  <p><strong>users</strong> - profiles of all users</p>
  <p><strong>partnership</strong> - users liked each other.</p>
  <p>How to find for a given user (use &quot;rrr&quot; as the user for this example)</p>
  <ul>
  <li>number of mutual likes</li>
  <li>profiles of mutual likers</li>
  </ul>
  <p>The expected output is count of 2 AND profiles of users &quot;abc&quot; and &quot;eee&quot; because both these users have mutually liked &quot;rrr&quot;.</p>
  <p>Here is the db</p>
  <pre><code>db={
    users: [
      {
        _id: &quot;abc&quot;,
        name: &quot;abc&quot;,
        group: 1
      },
      {
        _id: &quot;xyz&quot;,
        name: &quot;xyyy&quot;,
        group: 1
      },
      {
        _id: &quot;123&quot;,
        name: &quot;yyy&quot;,
        group: 1
      },
      {
        _id: &quot;rrr&quot;,
        name: &quot;tttt&quot;,
        group: 1
      },
      {
        _id: &quot;eee&quot;,
        name: &quot;uuu&quot;,
        group: 1
      }
    ],
    partnership: [
      {
        _id: &quot;abc_123&quot;,
        fromUser: &quot;abc&quot;,
        toUser: &quot;123&quot;
      },
      {
        _id: &quot;eee_rrr&quot;,
        fromUser: &quot;eee&quot;,
        toUser: &quot;rrr&quot;
      },
      {
        _id: &quot;rrr_abc&quot;,
        fromUser: &quot;rrr&quot;,
        toUser: &quot;abc&quot;
      },
      {
        _id: &quot;abc_rrr&quot;,
        fromUser: &quot;abc&quot;,
        toUser: &quot;rrr&quot;
      },
      {
        _id: &quot;xyz_rrr&quot;,
        fromUser: &quot;xyz&quot;,
        toUser: &quot;rrr&quot;
      },
      {
        _id: &quot;rrr_eee&quot;,
        fromUser: &quot;rrr&quot;,
        toUser: &quot;eee&quot;
      },
      
    ]
  }
  </code></pre>
  <p><a href="https://mongoplayground.net/p/jnW6fPOTd8I" rel="nofollow noreferrer">https://mongoplayground.net/p/jnW6fPOTd8I</a></p>