Skip to content

Commit

Permalink
加上数组支持
Browse files Browse the repository at this point in the history
  • Loading branch information
alsotang committed Nov 6, 2014
1 parent 88c4f35 commit 1b47322
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var crawler = require('./crawler');
var model = require('./model');
var Post = model.Post;
var config = require('./config');
var moment = require('moment');

mongoose.connect(config.mongodb_url);

Expand All @@ -27,7 +26,13 @@ var cities = [
{key: 'beijing', name: '北京'},
{key: 'chengdu', name: '四川成都'},
{key: 'nanning', name: '广西南宁'},
{key: 'changsha', name: '湖南长沙'}
{key: 'changsha', name: '湖南长沙'},
{key: 'changsanjiao', name: '长三角', names: [
'浙江杭州', '浙江温州', '浙江宁波', '浙江台州',
'浙江嘉兴', '浙江金华', '浙江绍兴', '浙江湖州',
'浙江丽水', '浙江衢州', '浙江舟山', '上海',
]
},
];

app.get('/', function (req, res, next) {
Expand All @@ -47,8 +52,9 @@ app.get('/all', function (req, res, next) {

for (var i = 0; i < cities.length; i++) {
(function (city) {
var names = city.names || [city.name];
app.get('/city/' + city.key, function (req, res, next) {
Post.find({author_location: city.name}).sort({create_at: -1}).limit(100).exec(function (err, docs) {
Post.find({author_location: {$in: names}}).sort({create_at: -1}).limit(100).exec(function (err, docs) {
if (err) {
return next(err);
}
Expand Down

0 comments on commit 1b47322

Please sign in to comment.