如何使用Mongodb和Node.js创建同类群组查询

时间:2019-06-28 07:39:57

标签: node.js mongodb mongoose

我需要创建如下的同类群组分析

Cohort Analysis Data set

我有两个集合,一个是公司,另一个是乔布斯。公司的userId和Jobs集合也具有userId(由用户创建),并且两个集合都已经创建好。我需要获取数据,例如我上传的图片

用户集合拥有

{
    "_id" : "00008600-7abe-11e9-a8b7-0990e4c9a64f",
    "userStatus" : true,
    "companyName":"Deskera"
    "userId" : "fdf15510-7abd-11e9-a8b7-0990e4c9a64f",
    "createdAt" : ISODate("2019-05-20T05:13:27.391Z")
},
{
    "_id" : "00008600-7abe-11e9-a8b7-0990e4c9a64f",
    "userStatus" : true,
    "companyName":"SPH"
    "userId" : "9da590d0-82ac-11e9-912f-6d24bccef9c7",
    "createdAt" : ISODate("2019-05-20T05:13:27.391Z")
}...30 more

作业收藏有

{
    "_id" : "001d2af0-82af-11e9-af65-6b843873ebb1",
    "userId" : "fdf15510-7abd-11e9-a8b7-0990e4c9a64f",
    "status" : "open",
    "expiryDate" : ISODate("2019-05-30T07:46:14.431Z"),
    "createdAt" : ISODate("2019-05-30T07:46:14.433Z")
},
{
    "_id" : "001d2af0-82af-11e9-af65-6b843873ebb1",
    "userId" : "fdf15510-7abd-11e9-a8b7-0990e4c9a64f",
    "status" : "open",
    "expiryDate" : ISODate("2019-05-30T07:46:14.431Z"),
    "createdAt" : ISODate("2019-05-30T07:46:14.433Z")
},
{
    "_id" : "001d2af0-82af-11e9-af65-6b843873ebb1",
    "userId" : "9da590d0-82ac-11e9-912f-6d24bccef9c7",
    "status" : "open",
    "expiryDate" : ISODate("2019-05-30T07:46:14.431Z"),
    "createdAt" : ISODate("2019-05-30T07:46:14.433Z")
},
{
    "_id" : "001d2af0-82af-11e9-af65-6b843873ebb1",
    "userId" : "9da590d0-82ac-11e9-912f-6d24bccef9c7",
    "status" : "open",
    "expiryDate" : ISODate("2019-05-30T07:46:14.431Z"),
    "createdAt" : ISODate("2019-05-30T07:46:14.433Z")
}... 754 more

0 个答案:

没有答案