How can I get the details of the user that has performed DML operations like insert/delete/update to a collection?
The document in the oplog/ChangeStream doesn’t have any information on the user that has performed the operation.
I see db.getUsers() or db.runCommand( { usersInfo: 1 } ) to fetch the user details but not sure how to associate these user details with the document that has been inserted.
I think you’re looking for Auditing. However this feature is part of the MongoDB Enterprise Server, which requires an Enterprise Advanced subscription if you’re looking for an on-prem deployment of this feature.