No, neither in Mongo, nor in any other database should you query a database in a loop. And one good reason for this is performance: in most web apps, database is a bottleneck and devs trying to make as small amount of db calls as possible, whereas here you are trying to make as many as possible.
I mongo you can do what you want in many ways. Some of them are:
- putting your tags inside the document
{itemName : 'item', tags : [1, 2, 3]}
- knowing the list of elements, you do not need a loop to find information about them. You can fetch all results in one query with $in :
db.tags.find({ field: { $in: [<value1>, <value2>, ... <valueN> ] }})