title: Mongodb find subset in array field from input array
body: <p>Suppose I have db as below,</p>
  <pre><code>const data = [
    {
      &quot;chapter&quot;: 1,
      &quot;targets&quot;: [
        {
          type: 'user',
          recipientId: 1
        }
      ],
      &quot;challenge&quot;: [
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-1&quot;
        },
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-2&quot;
        },
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-3&quot;
        },
      ]
    },
    {
      &quot;chapter&quot;: 1,
      &quot;targets&quot;: [
        {
          type: 'user',
          recipientId: 2
        }
      ],
      &quot;challenge&quot;: [
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-2&quot;
        },
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-3&quot;
        },
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-4&quot;
        },
      ]
    },
    {
      &quot;chapter&quot;: 1,
      &quot;targets&quot;: [
        {
          type: 'user',
          recipientId: 3
        }
      ],
      &quot;challenge&quot;: [
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-4&quot;
        },
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-5&quot;
        },
      ]
    },
    {
      &quot;chapter&quot;: 1,
      &quot;targets&quot;: [
        {
          type: 'user',
          recipientId: 4
        }
      ],
      &quot;challenge&quot;: [
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-2&quot;
        },
        {
          &quot;activate&quot;: false,
          &quot;challengeId&quot;: &quot;ch-3&quot;
        },
        {
          &quot;activate&quot;: true,
          &quot;challengeId&quot;: &quot;ch-4&quot;
        },
      ]
    },
  ],
  </code></pre>
  <p>and I want to query using an array of <code>recipientId</code> if I input
  <code>[1,2]</code> it should turn the intersect of <code>challengeId</code> the expected output is</p>
  <pre><code>[
  {&quot;challengeId&quot;: &quot;ch-2&quot;},
  {&quot;challengeId&quot;: &quot;ch-3&quot;}
  ]
  </code></pre>
  <p>if the input is <code>[1,2,3]</code> it should return <code>[]</code> because there is no intersection with this input</p>
  <p>and if the input is <code>[1,2,4]</code> also return</p>
  <pre><code>[
  {&quot;challengeId&quot;: &quot;ch-2&quot;},
  ]
  </code></pre>
  <p>because <code>challengeId ch-3</code> of <code>recipientId 4</code> does not activate yet.</p>
  <p>I have been reading <code>$setIntersection</code> but it seems does not solve my issue.</p>
  <p>Any suggestion?
  Thanks.</p>