Skip to content

Commit

Permalink
Let DB queries run concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
pfleidi committed Jan 9, 2016
1 parent 40482d8 commit d993f3e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions routes/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const _ = require('lodash');
const Promise = require('bluebird');

module.exports = function api(config, models) {
let Download = models.Download;
Expand All @@ -26,12 +27,11 @@ module.exports = function api(config, models) {
}

return function (req, res) {
fetchMetaData().then(function (allData) {
fetchFiles().then(function (fileData) {
res.json(
_.merge(allData, { files: fileData })
);
});
Promise.all([fetchMetaData(), fetchFiles()]).then(function (results) {
let metaData = results[0];
let filesData = results[1];

res.json(_.merge(metaData, { files: filesData }));
});
};
};

0 comments on commit d993f3e

Please sign in to comment.