我有一个包含主队和客队变量的球队,我现在有下面的代码来显示每场比赛的主队名称,我将如何更改它以便我显示每场比赛的主队和客队所以它看起来像下面这样:
[
"Team 1", "Team 2",
"Team 3", "Team 4"
]
例如,1/2 队参加一场比赛,3/4 队参加另一场比赛。
app.get('/homeTeamNames', function(req, res) {
util.log('Serving request for url [GET] ' + req.route.path);
Match.find({}, {'hometeam': 1}).populate('hometeam', {name: 1}).exec(function(err, teams) {
var homeNames = [];
for(var i = 0; i < teams.length; i++) {
homeNames.push(teams[i].hometeam.name);
}
res.send(homeNames);
});
});