title: Export mongoose query function
body: <p>Im making script in my app, that will work not on routes, but always active.
  I did another controller file, but faced to the problem. My module.exports doesnt work with mongoose query, i mean, nothing happens. Others  operations works. What did i do wrong?</p>
  
  <pre><code>const Model = require("model");
  
  module.exports = () =&gt; {
  
      setInterval(() =&gt; {
          console.log('interval');
      }, 2000);
  
      Model.findOne({name: 'test'}).then((result) =&gt; {
          console.log(result);
      }).catch((err) =&gt; {
          console.log(err);
      });
  }
  </code></pre>
  
  <p>'interval' is showing, and result is not. In my other app i did the same thing and its works without problem! Ofcourse these apps has different architecture, but still... Can't find answer in google.</p>
  
  <p>UPDATE</p>
  
  <p>I have the mongoose connection listener</p>
  
  <pre><code>mongoose.connection.on('connected', function () {
      console.log("connected");
  });
  </code></pre>
  
  <p>Tried to put code above there, and it doesnt work either.</p>