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;
时间: 2024-10-12 11:49:59