每个城市我都有几个条目。如何获取每个城市的最新 3 个条目?喜欢:
城市
1记录1
记录2
记录3
城市2
记录1
记录2
记录3城市
3
记录1
记录2
记录3
架构:
var schema = mongoose.Schema({
city: {type: String},
title: {type: String},
created: {type: Number, default: Math.floor(new Date() / 1000)}
})
Run Code Online (Sandbox Code Playgroud)
我试过的代码:
Collection
.find('location $in ' + cities)
.aggregate({$group: {location: "$location"}})
.sort('created: 1')
.limit(3).exec(function(err, docs) { res.render('index', { hash: docs }); });
Run Code Online (Sandbox Code Playgroud)
那么,如何在我应该得到的结果中执行查询:每个城市的 3 个最近的标题
我正在寻找一种在 youtube api 上管理广告的方法。有办法吗?我只找到了 adwords api。它可以用于 ytb 广告吗?