title: How do you instruct mocha/nodejs to wait till all db operations are over
body: <p>I'm trying to test if some of my db operations are executed properly. The flow is as follows (I'm using mocha for testing)</p>
  
  <ol>
  <li>Call code which loops through data and saves it to redis</li>
  <li>Get data from redis (in my testcase)  to see if it saves the right data.</li>
  </ol>
  
  <p>I'm noticing that the get data from db gets executed much before anything is saved. I was looking at the done() option in mocha, however that seems to work only if data is saved through mocha (setup etc).</p>
  
  <p>So how do I instruct mocha to wait for all db to be saved before trying to retrieve from db?</p>
  
  <p>Thanks for any help</p>