2017-04-03 103 views

回答

1

看看$lookup,在那里你可以有点join两个集合

db.product.aggregate(
{ 
    $lookup: { 
    from: 'category', 
    localField: 'categoryRef', 
    foreignField: 'catId', 
    as: 'category' 
    }, 
    {$unwind: '$category'}, 
    {$match: {'category.name': "testCat"}} 
}) 
+0

查找查找^^ –

+0

返回空数组.... –

+0

我发现的方式,但它不到风度工作,它会填充每个产品与所有类别... –