У меня есть следующие 2 JSON объекта в моем MongoDB
JSON - 1:
{
"projectId" : 10003,
"boardId" : 2,
"sprintId" : 3,
"epicId" : 10018,
"storyId" : 10066,
"name" : "Landing Screen",
"status" : "Closed",
"state" : "Closed",
"estimate" : 5,
"estimatedTime" : 0,
"jiraUpdatedDate" :1580208341294,
"changes" : [
{
"changeId" : "24623",
"changeCreatedDateTime" :1580208341304,
"updates" : [
{
"field" : "status",
"fieldtype" : "jira",
"fieldId" : "status",
"from" : "5",
"fromString" : "Resolved",
"to" : "6",
"toString" : "Closed"
}
],
"authorIsDeleted" : "true",
"authorState" : "Inactive",
"authorUsername" : null,
"authorFullName" : "",
"authorShortName" : null
},
{
"changeId" : "12755",
"changeCreatedDateTime" :1576222479010,
"updates" : [
{
"field" : "assignee",
"fieldtype" : "jira",
"fieldId" : "assignee",
"from" : "asfasfasfasf",
"fromString" : "Girish",
"to" : "bfbasgafasfas",
"toString" : "Animesh"
}
],
"authorID" : "asfsafsafsas",
"authorIsDeleted" : "false",
"authorState" : "Active",
"authorUsername" : null,
"authorFullName" : "Harish",
"authorShortName" : null
},
{
"changeId" : "10795",
"changeCreatedDateTime" : 1575028807038,
"updates" : [
{
"field" : "Sprint",
"fieldtype" : "custom",
"fieldId" : "SprintData",
"from" : "",
"fromString" : "",
"to" : "3",
"toString" : "Sprint 2"
}
],
"authorID" : "bfbasgafasfas",
"authorIsDeleted" : "true",
"authorState" : "Inactive",
"authorUsername" : null,
"authorFullName" : "Animesh",
"authorShortName" : null
},
{
"changeId" : "10794",
"changeCreatedDateTime" : 1575028793243,
"updates" : [
{
"field" : "summary",
"fieldtype" : "jira",
"fieldId" : "summary",
"from" : null,
"fromString" : "Landing Screen - Enhancement",
"to" : null,
"toString" : "Landing Screen"
}
],
"authorID" : "bfbasgafasfas",
"authorIsDeleted" : "true",
"authorState" : "Inactive",
"authorUsername" : null,
"authorFullName" : "Animesh",
"authorShortName" : null
}
],
"type" : "Story",
"typeId" : 10003,
"createdDate" : 1589984431264
}
JSON - 2 :
{
"projectId" : 10003,
"boardId" : 2,
"sprintId" : 11,
"epicId" : null,
"storyId" : 12202,
"name" : "MarTech Fixes",
"status" : "In Progress",
"state" : "In Progress",
"estimate" : 2,
"estimatedTime" : 0,
"jiraUpdatedDate" : 1589864759510,
"changes" : [
{
"changeId" : "51255",
"changeCreatedDateTime" : 1589864759514,
"updates" : [
{
"field" : "Fix Version",
"fieldtype" : "jira",
"fieldId" : "fixVersions",
"from" : null,
"fromString" : null,
"to" : "10194",
"toString" : "1.0.8(4)"
}
],
"authorID" : "asfasfasf",
"authorIsDeleted" : "false",
"authorState" : "Active",
"authorUsername" : null,
"authorFullName" : "ankit",
"authorShortName" : null
},
{
"changeId" : "40223",
"changeCreatedDateTime" : 1585661512213,
"updates" : [
{
"field" : "Sprint",
"fieldtype" : "custom",
"fieldId" : "SprintData",
"from" : "5",
"fromString" : "Sprint 4",
"to" : "6",
"toString" : "Sprint 5"
}
],
"authorID" : "bfbasgafasfas",
"authorIsDeleted" : "true",
"authorState" : "Inactive",
"authorUsername" : null,
"authorFullName" : "Animesh",
"authorShortName" : null
},
{
"changeId" : "40045",
"changeCreatedDateTime" : 1585636672629,
"updates" : [
{
"field" : "Rank",
"fieldtype" : "custom",
"fieldId" : "customfield_10019",
"from" : "",
"fromString" : "",
"to" : "",
"toString" : "Ranked higher"
}
],
"authorID" : "bfbasgafasfas",
"authorIsDeleted" : "true",
"authorState" : "Inactive",
"authorUsername" : null,
"authorFullName" : "Animesh",
"authorShortName" : null
}
],
"type" : "Task",
"typeId" : 10004,
"createdDate" : 1589984431264
}
Мой запрос MongoDB:
db.getCollection('stories').find({
'projectId': 10003,
'changes.updates.fieldId': 'SprintData',
'changes.updates.from': '5',
'type': {'$in': ['Story', 'Task']}
})
В качестве части результата я должен получить только JSON 2 там, где есть fieldId: SprintData и from: '5' вместе в одном объекте не разные.
Каким должен быть мой запрос Mon go? Я пробовал использовать Map Reduce, но больше не знаю об этом.
Заранее спасибо.