I have a table `Thread`:

```
{
  userId: String
  messageId: String
}

```

Now I have an array of `userIds`, I need to query 20 messageIds for each of them, I can do it with a loop:

```
const messageIds = {}
for (const userId of userIds) {
  const results = await Thread.find({ userId }).sort({ _id: -1 }).limit(20).exec()
  messageIds[userId] = results.map(result => result.messageId)
}

```

But of course this doesn't perform well. Is there a better solution?