title: How would I be able to query depending on array length?
body: <p>I have a project where a user selects a group and then can choose what role they are looking for in that group.</p>
  <p>It looks something like this:</p>
  <pre><code>let group = await models.Group.findById(user.groupID);
  let seekGroupRole = await models.GroupRole.findById(user.seekingGroupRole);
  
  let test = await models.Profile.aggregate([
            {
              $match: {
                $or: [
                  { _id: { $in: group.members } },
                  { _id: { $in: seekGroupRole.profiles } },
                ],
              },
            },
            { $group: { _id: &quot;$_id&quot; } },
  ]);
  console.log(test);
  </code></pre>
  <p>Now we are adding a way to select multiple roles. How would I go about doing this without having to do multiple queries?</p>
  <p>Is something like this possible?</p>
  <pre><code>let group = await models.Group.findById(user.groupID);
  let seekGroupRole = await models.GroupRole.find({
      _id: { $in: user.seekingGroupRole}
  });
  
  let test = await models.Profile.aggregate([
            {
              $match: {
                $or: [
                  { _id: { $in: group.members } },
                  { _id: { $in: seekGroupRole.profiles } },
                ],
              },
            },
            { $group: { _id: &quot;$_id&quot; } },
  ]);
  console.log(test);
  </code></pre>
  <p>Now <code>seekGroupRole</code> is an array. It could have the length of 1 or more. So it would be <code>seekGroupRole[0].profiles, seekGroupRole[1].profiles,</code> etc...</p>
  <p>What is the best way to accomplish this? Should I for loop and merge the results?</p>