Get random filtered values in mongoose (nodejs)

I'm writing a simple app to keep a list of questions to generate random exams. I defined this schemas:

Question schema:

var questionSchema = mongoose.Schema({
  text: String,
  type: {
    type: String,
    enum: ['multichoice', 'numerical', 'truefalse']
  },
  meta: {
    votes: {
      type: Number,
      default: 0
    },
    tags: [{
      type: mongoose.Schema.Types.ObjectId,
      ref: 'tag'
    }]
  }
});

Tag schema:

var tagSchema = mongoose.Schema({
  name: {
    type: String,
    unique: true
  }
});

What I'm trying to do is to get random questions (I'm using mongoose-random) filtering by tags, and here is the problem. My get route receive a list of comma separated tag names. How can I filter questions regarding if they contain that tag name? At the moment questions only have a list of tag ids and I don't see a way to do this.

At this moment this is the code used to fetch random questions:

Question.findRandom().limit(req.query.maxquestions).exec(function (err, questions) {
    if (err) {
        res.send(err);
    } else {
        res.set('Content-Type', 'text/json');
        res.json(questions);
    }
});

EDIT: This is my actual code to solve the problem

router.get('/exam', function(req, res) {
  var tags = req.query.tags.split(",");
  var tagsIds;
  var tagsProcessed = 0;

  var eventEmitter = new events.EventEmitter();
  eventEmitter.on('tagProcessed', function() {
    tagsProcessed++;

    if (tagsProcessed >= tags.length) {
      switch (req.query.format) {
        case "json":
        case "xml":
          break;
        case "html":
        default:
          if (req.isAuthenticated()) {
            console.log(tagsIds);
            Question.findRandom({'meta.$.tags': {$in: tagsIds}}).limit(req.query.questions).exec(function (err, questions) {
              if (err) {
                res.send(err);
              } else {
                res.set('Content-Type', 'text/html');
                res.render('exam', {
                  title: 'Smarty',
                  user: req.user,
                  questions: questions,

                });
              }
            });
          } else {
            res.redirect('/');
          }
      }
    }
  });

  if (tags.length > 0) {

    for (var i = 0; i < tags.length; i++) {
      Tag.find({name: tags[i]}, function(err, tag) {
        tagsIds.push(tag);
        eventEmitter.emit('tagProcessed');
      });
    }
  } else {
    eventEmitter.emit('tagProcessed');
  }
});

I tried to change the filter to:

Question.findRandom({'meta.$.tags': {$in: tagsIds}}).limit(req.query.questions).exec(function (err, questions) {

but I get the same result, an error that only shows {} (no message).

EDIT 2: There was a problem in my list of tag ids. I also changed the filter to {'meta.tags': { $in: tagsIds }} and now works but I have a little problem. If I had a question with tags foo and bar and I send a get request with tag foo, this question is not returned. How can I fix this?

EDIT 3: I was saving bad values. The solution proposed (with the filter modification) works.

Here is the way I would suggest you to go with. Find all the tags first with the tag names you are getting from your route. Get all the ID's of tag names you have. Next is to find all the random questions which the tag ID's associated with them.

Question.findRandom({tags: {$in: TAG_IDS}}).limit(req.query.maxquestions).exec(function (err, questions) {

});

That's all you need to do.