one query inside another MongoDB hangs
<p>I am trying to get only get Notes [from the notes collection] that come from meetings [from the meetings collection] that don't contain the word 'test' in them:</p>

<pre><code>function getNotes(done) {
  noteSchema.find({}).exec((err, notes) =&gt; {
    var numNotes = 0;
    async.each(notes, (n, next) =&gt; {
                userSchema.findById(n.userId, (err, user) =&gt; {
                if (err || !user) { next(); return; }
                var emailsStr = utils.getEmailsString(user.emails);
                if (!utils.toSkipEmail(emailsStr)) {
                    meetingSchema.findById(n.meetingId, (err, meeting)  =&gt; {
                    if (err || !meeting) { next(); return; }
                        if (meeting.name.displayValue.indexOf('test', 'Test') == -1) {
                            numNotes++;
                }
              next();
              });
            }
          })
    }, (err, result) =&gt; {
      console.log(util.format('Total Number of Notes: %d', numNotes));
      done(null);
    });
  });
}
</code></pre>

<p>The code works fine without adding in the lines to find the meetings by ID. It hangs at that point.</p>

<p>For reference, here is the start of a function that comes later to filter out any 'test' or 'Test' containing meetings.</p>

<pre><code>function getMeetings(done) {
  meetingSchema.find({
    'name.displayValue': { '$regex' : '(?!.*test)^.*$' , '$options' : 'i' }
  }).exec((err, meetings) =&gt; {
</code></pre>

<p>Relevant lines of Notes Schema:</p>

<pre><code>var mongoose = require('mongoose');

var Schema = mongoose.Schema;

var noteSchema = mongoose.Schema({
    meetingId: {type: String, default: ''},
});

exports.Note = mongoose.model('Note', noteSchema);
</code></pre>

<p>The meeting schema has no notes field.</p>