Created
March 21, 2016 04:36
-
-
Save colwem/63a59d607fae0320f556 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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