Skip to content

Instantly share code, notes, and snippets.

@colwem
Created March 21, 2016 04:36
Show Gist options
  • Select an option

  • Save colwem/63a59d607fae0320f556 to your computer and use it in GitHub Desktop.

Select an option

Save colwem/63a59d607fae0320f556 to your computer and use it in GitHub Desktop.
function getConnection(connectionString) {
return Promise.try(() => {
return mongoose.connect(uri);
})
.disposer(() => {
mongoose.disconnect();
})
}
Promise.using(getConnection(uri), (connection) => {
const User = require('../../models/user');
return User.find({UTCCronTime: hour});
})
.each((user) => {
return api.getUser(user);
})
.catch((err) => {
return console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment