mongodb语句查询问题

图片描述

我想用mongoose查询我表里的数据,希望查询语句返回的数据格式如下:

[
    {
       outtag:"技术",
       outtagCount:100,
       intagArray:[
           {
               intag:"高端职位",
               intagCount:25
           },
           {
               intag:"测试",
               intagCount:22
           },
       ] 
    },
    {
       outtag:"产品",
       outtagCount:85,
       intagArray:[
           {
               intag:"产品经理",
               intagCount:20
           },
           {
               intag:"架构师",
               intagCount:17
           },
       ] 
    }
]

这样能做到么?如果能的话,我的查询语句该怎么写?
求各位大佬回答下~

阅读 1.8k
1 个回答

引入mongoose模块,查询指令,user.find({查询字段:查询条件}).exec(err,data){}

推荐问题