Compte tenu de cette structure de collection DB:Get MongoDB collection embarqués docs
{
"_id" : ObjectId("59ba5bf6fa12aa446c097793"),
"tab" : "tab1",
"tabfeeds" : [
{
"url" : "//url1",
"limit" : 4,
"type" : "text"
},
{
"url" : "//url2",
"limit" : 8,
"type" : "normal"
}
]
}
{
"_id" : ObjectId("59ba73a6fa12aa446c097794"),
"tab" : "tab2",
"tabfeeds" : [
{
"url" : "//url5",
"limit" : 4,
"type" : "normal"
}
]
}
je peux obtenir toute la collection "onglets" comme ceci:
router.get('/tabs', function(req, res) {
var db = req.db;
var collection = db.get('tabs');
collection.find({},{},function(e,docs){
res.json(docs);
});
});
Et puis:
$.getJSON('/feeds/tabs', function(data) {
$.each(data, function(){
tablistcontent += '<th rel="' + this.tab + '">' + this.tab + '</th>';
});
});
Mais comment puis-je lister chaque élément de tabfeeds
pour chaque tab
?