猫鼬:查找一组特定文章的所有标签

路德维格·马格努森(Ludwig Magnusson)

我有此架构articleSchema:

{
    //other attributes
    tags : [ String ]
}

我想根据特定条件搜索文章,仅检索标签,然后从所有重复的文章中创建标签的单个数组。

mondgodb和mongoose中有任何内置功能吗?

路德维格·马格努森(Ludwig Magnusson)

正如WiredPrairie指出的那样,distinct解决方案就可以了。

var query = { /** Query for the articles that I want tags from */ };

//Using mongoose-q
return Article.distinctQ('tags', query);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章