Iam using MongoDB C#/.NET Driver version 2.11.5. Here is my collection structure.
CollectionName: Deployment
{
"_id" : ObjectId("60263b3279357e12775bfb21"),
"version" : "P3-V1.0",
"productId" : "6020f75d103d4895f12c88ec",
"hierarchy" : "6020f8ad103d4895f12c88ed",
"description" : "P3-T1-V1.0",
"policies" : [
{
"name" : "Policy-1",
"description" : "Policy-1",
"rules" : [
{
"subject" : "abc.def@xyz.com",
"status" : "InProgress",
"comments" : "",
"updatedBy" : "",
"approvalId" : "8f7c8767-6613-4aa2-9b87-7778a42512bd",
"requestDate" : ISODate("2021-02-12T08:29:32.000Z")
},
{
"subject" : "ghi.jkl@xyz.com",
"status" : "InProgress",
"comments" : "",
"updatedBy" : "",
"approvalId" : "9e7c8767-6613-4aa2-9b87-7778a42512ee",
"requestDate" : ISODate("2021-02-11T08:29:32.000Z")
}
]
},
{
"name" : "Policy-2",
"description" : "Policy-2",
"rules" : [
{
"subject" : "mno.pqr@xyz.com",
"status" : "InProgress",
"comments" : "",
"updatedBy" : "",
"approvalId" : "1a6c8767-6613-4aa2-9b87-7778a42512bd",
"requestDate" : ISODate("2021-02-12T08:29:32.000Z")
},
{
"subject" : "stu.vwx@xyz.com",
"status" : "InProgress",
"comments" : "",
"updatedBy" : "",
"approvalId" : "2z0c8767-6613-4aa2-9b87-7778a42512ee",
"requestDate" : ISODate("2021-02-11T08:29:32.000Z")
}
]
}
]
}
C# Class Names:
Deployment (has multiple IList<Policy> Policies
)
Policy (has multiple IList<Rule> Rules
)
Rule
What is the Update query to update status, comments and updatedBy fields in a Rule, given Policy.Name (for ex: Policy-1) and Rule.subject (for ex: abc.def@xyz.com)?
What is the Insert query to insert a new Rule object inside a Policy, given Policy.Name (for ex: Policy-1)?
Thanks for your help.