title: Is there an elegant way to render two sets of mongoose documents?
body: <p>I have a web page view that requires two sets of mongoose documents, one for "complete tasks" and one for "incomplete tasks."</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>router.get('/', (req, res) =&gt; {
    Task.find({'completed': false}) // Finding all incomplete tasks
      .exec()
      .then((incompleteTasks) =&gt; {
        Task.find({'completed': true}) // Finding all complete tasks
          .exec()
          .then((completeTasks) =&gt; {
            res.render('tasks/tasks', {
              title: 'Tasks',
              incompleteTasks: incompleteTasks,
              completeTasks: completeTasks,
            });
          });
      });
  });
  </code></pre>
  
  <p>Is there a way to make this more elegant? Right now, it isn't too bad, but if I had to split up my tasks into more than sets, the code would get pretty messy.</p>
  
  <p>What I thought of was to make the code have the following structure:</p>
  
  <pre><code>let incompleteTasks = /* Get INCOMPLETE tasks */
  let completeTasks = /* Get COMPLETE tasks */
  res.render('tasks/tasks', {
    title: 'Tasks',
    incompleteTasks: incompleteTasks,
    completeTasks: completeTasks,
  });
  </code></pre>
  
  <p>However, because of the asynchronous nature of mongoose queries, I'm not sure how to do this.</p>
  
  <p>Any suggestions?</p>