This is my data structure
{
"_id" : ObjectId("57f37f18517f72bc09ee7632"),
"name" : "testdata",
"createdBy" : "57f1fdef1d3c40141617d215",
"transitionEnabled" : false,
"status" : "active",
"createdDateTime" : ISODate("2016-10-04T10:06:16.195Z"),
"accounts" : [
"57f37f75517f72bc09ee7634"
],
"deliverables" : [],
"risks" : [],
"issues" : {
"_id" : ObjectId("57f38398517f72bc09ee7680"),
"title" : "test",
"description" : "Delay in testing due to issues with Provider Finder dataload in the test region. This has impacted the production release planned for Sep 30th",
"plannedStartDate" : ISODate("2016-09-01T00:00:00.000Z"),
"plannedEndDate" : ISODate("2016-10-30T00:00:00.000Z"),
"assignedTo" : "57f375ea517f72bc09ee762a",
"createdBy" : ObjectId("57f375ea517f72bc09ee762a"),
"likes" : 0,
"createdDateTime" : ISODate("2016-10-04T10:25:28.301Z"),
"status" : "open",
"stakeholders" : [],
"__v" : 0,
"lastUpdatedTime" : ISODate("2019-11-15T09:19:06.279Z")
},
"__v" : 0
}
I would like to select all the issues group by the organization and I want to implement sort,limit and skip for those data(the sub array issues data only from the above). For that I've tried the following code
db.organizations.aggregate([
{
"$lookup" : {
"from" : "issues",
"localField" : "issues.str",
"foreignField" : "_id.str",
"as" : "issues"
}
},
{$sort: {weight: -1, "issues.lastUpdatedTime": 1}}
{
$group:
{
_id: "$issues",
},
},
])
I am getting the result as follows.
How to sort and set limit and skip for the below query? Results returned by the query is also attached.
But I not need the outer _id field which shown in the above result. Please help me to solve this problem.