title: How to wait for the return of a Mongoose search?
body: <p>I created a CRUD with NodeJS / Mongoose, split the files in MVC style. In route example I show up below, when the <code>retrieveOne</code> routine is executed, it's necessary to wait for its processing and then redirect the user to one route or another. I'd like to use Bluebird to wait for processing. I need some help to implement the routine.</p>
  
  <p>Index.js -----------------------------------------------</p>
  
  <pre><code>const myCRUD = require('./api/controllers/controller')
  
  router.post('/login', function(req, res, next) {   
  
     // HOW TO IMPLEMENT BLUEBIRD HERE?
  
     // How to wait for the "retrieveOne" process and a then do a "if" test (below)?   
     let ret = myCRUD.retrieveOne({ name: "abc test" }); 
  
  
     if(!ret) {
        res.redirect('/success')
     } else {
        res.redirect('/error')
     }
  })
  </code></pre>
  
  <p>controller.js ------------------------------------------</p>
  
  <pre><code>const mongoose = require('mongoose');
  const Schema = require('./schema-user');
  const Model = mongoose.model('users', Schema);
  
  const CRUD = {
     retrieveOne: function(query) {
        Model.findOne(query, function(err, result) {
           if (err) return err;
           return result;
        });
     }
  }
  
  module.exports = CRUD;
  </code></pre>
  
  <p><strong>Note</strong>: I've already found several examples with and without Bluebird right here in S.O., but I couldn't get it to work:
  Examples: <a href="https://stackoverflow.com/questions/33269384/how-to-wait-mongoose-exec-function-to-be-done">1</a>, <a href="https://stackoverflow.com/questions/6180896/how-to-return-mongoose-results-from-the-find-method">2</a>, <a href="https://stackoverflow.com/questions/50454854/how-to-wait-for-mongoose-list-item-to-be-pushed">3</a>, <a href="https://stackoverflow.com/questions/54613321/wait-for-mongoose-to-resolve-data-before-returning">4</a>, <a href="https://stackoverflow.com/questions/21606965/how-to-wait-for-the-result-of-a-mongoose-query">5</a></p>