title: NodeJs Mongoose Promise then/catch
body: <p>Faced an issue with Mongoose promises</p>
  
  <pre><code>MyModel.find().then((data)=&gt; Promise.reject())
         .catch(()=&gt;console.log('first catch'))
         .then(()=&gt;console.log('ok'))
         .catch(()=&gt;console.log('second catch'));
  </code></pre>
  
  <p>after the execution I get </p>
  
  <pre><code>first catch
  second catch
  </code></pre>
  
  <p>But if I do it with only native Promises:</p>
  
  <pre><code>Promise.reject()
         .catch(()=&gt;console.log('first catch'))
         .then(()=&gt;console.log('ok'))
         .catch(()=&gt;console.log('second catch'));
  </code></pre>
  
  <p>after the execution I get </p>
  
  <pre><code>first catch
  ok
  </code></pre>
  
  <p>that is ok in terms of Promise <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch" rel="nofollow">docs</a></p>
  
  <p>It seems that Mongoose uses own <code>promise implementation</code></p>
  
  <p>I have found that I can solve that by doing the following</p>
  
  <pre><code>new Promise((resolve, reject) =&gt; { MyModel.find().then((data) =&gt; reject()) })
         .catch(()=&gt;console.log('first catch'))
         .then(()=&gt;console.log('ok')
         .catch(()=&gt;console.log('second catch'));
  </code></pre>
  
  <p>It works as it should according the docs:</p>
  
  <pre><code>first catch
  ok
  </code></pre>
  
  <p>Any suggestion how to work with that better?</p>