diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-08 05:37:20 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-08 05:37:20 +0100 |
| commit | 9978bb56fc2c56ad52930bde9bcaa561158a158a (patch) | |
| tree | 0998cfc21091c6923b0bf3988a35ff82f1e58e98 /bucky/search/middleware.js | |
| parent | dd45551e4bf64ba472976b60986b9273449aae70 (diff) | |
searches working correctly
Diffstat (limited to 'bucky/search/middleware.js')
| -rw-r--r-- | bucky/search/middleware.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bucky/search/middleware.js b/bucky/search/middleware.js index b9487b1..39d7a71 100644 --- a/bucky/search/middleware.js +++ b/bucky/search/middleware.js @@ -7,16 +7,29 @@ module.exports = { search: function (req, res, next) { res.search = search.search(req.query.query, req.query.start, req.query.limit) console.log(res.search) - next() }, + getThreads: function (req, res, next){ + var thread_ids = res.search.thread_ids; + if (! thread_ids || ! thread_ids.length) { + return next() + } + db.getThreadsById(thread_ids).then(function(threads){ + res.search.threads = threads + next() + }) + }, + getComments: function (req, res, next){ var comment_ids = res.search.comment_ids; if (! comment_ids || ! comment_ids.length) { return next() } db.getCommentsById(comment_ids).then(function(comments){ + comments.forEach(function(comment){ + comment.set('comment', comment.get('comment').toString()) + }) res.search.comments = comments next() }) |
