Hi,
I want to ask for help with how to do this in MongoDB.
I created a collection named “resources” which contains the resources in my school like computers.
I have created the following collection.
[{
"description": "PC-13",
"comments": "",
"parts": [
{
"id": "PARTS-23aq",
"type": "mouse",
"description": ""
},
{
"id": "PARTS-18be",
"type": "keyboard",
"description": ""
},
{
"id": "PARTS-53ih",
"type": "monitor",
"description": ""
}
]
}, {
"description": "PC-09",
"comments": "",
"parts": [
{
"id": "PARTS-31me",
"type": "monitor",
"description": ""
},
{
"id": "PARTS-36hs",
"type": "mouse",
"description": ""
},
{
"id": "PARTS-74bc",
"type": "keyboard",
"description": ""
}
]
}, {
"description": "PC-49",
"comments": "",
"parts": [
{
"id": "PARTS-48up",
"type": "monitor",
"description": ""
},
{
"id": "PARTS-90hz",
"type": "mouse",
"description": ""
},
{
"id": "PARTS-14zg",
"type": "keyboard",
"description": ""
}
]
}
]
Now, I wanted to execute an “audit” where I would check the status of my resources.
So basically, in my application administrator would verify each computer resource part if they are still in order. If they are still working, in failure, etc.
I would like to create a document in a separate collection named “resources_audit” where I could transfer the content of one collection (resources) into another (resources_audit).
In that document, I would log the date of the audit, who did the audit, and the audit status for each resource.
Similar to the one below
{
"_id": ObjectId("507f1f77bcf86cd799439011"),
"audit_date": ISODate("2023-10-03T08:00:00.000Z"),
"status": "IN-PROGRESS",
"audit_notes": {
"comments": "IN-PROGRESS",
"auditor": "Jane Doe",
"result": [{
"description": "PC-13",
"comments": "",
"audit_overall_status": "IN-PROGRESS",
"parts": [
{
"id": "PARTS-23aq",
"type": "mouse",
"description": "",
"audit_status": "PASSED"
},
{
"id": "PARTS-18be",
"type": "keyboard",
"description": "",
"audit_status": "PASSED"
},
{
"id": "PARTS-53ih",
"type": "monitor",
"description": "",
"audit_status": "PASSED"
}
]
}, {
"description": "PC-09",
"comments": "",
"parts": [
{
"id": "PARTS-31me",
"type": "monitor",
"description": "",
"audit_status": "IN-PROGRESS"
},
{
"id": "PARTS-36hs",
"type": "mouse",
"description": "",
"audit_status": "FAILED"
},
{
"id": "PARTS-74bc",
"type": "keyboard",
"description": "",
"audit_status": "PASSED"
}
]
}, {
"description": "PC-49",
"comments": "",
"parts": [
{
"id": "PARTS-48up",
"type": "monitor",
"description": "",
"audit_status": "IN-PROGRESS"
},
{
"id": "PARTS-90hz",
"type": "mouse",
"description": "",
"audit_status": "IN-PROGRESS"
},
{
"id": "PARTS-14zg",
"type": "keyboard",
"description": "",
"audit_status": "IN-PROGRESS"
}
]
}
]
}
}
Is what I am thinking feasible? Or how could this be done?