thanks使用注意事项;

 1 router.get('/api/users/search/:key/:page', function(req, res) {
 2     if(_.isEmpty(req.params.key)) { res.json({items:null}); return; }
 3 
 4     var key = urlencode.decode(req.params.key);
 5     var page = parseInt(req.params.page);
 6     if(!page) page = 0;
 7     var query = {nickname: new RegExp(key, "i")};
 8     thunk.all([
 9       thunk(function(cb) { User.find(query).skip(page * 40).limit(40).exec(function(err, items) { cb(err, items); }); }),
10       thunk(function(cb) { User.count(query).exec(function (err, count) { cb(err, count); }); })
11     ])(function(cb, results) {
12       res.json({items: results[0], total:results[1]});
13     });
14   });

thunk.all()();

两个()连用,中间没有then;

posted @ 2016-02-16 09:34  挥刀  阅读(281)  评论(0编辑  收藏  举报