Using Mongodb oplog to track data change history

I am considering using MongoDB for an application. I am new to MongoDB. I need to track changes made by users to the system, what was added / changed and when. It seems that oplog contains all the data I need, and it seemed to me that saving a copy of oplog to a separate collection that was not displayed would provide me with all the history I needed. It does not need to be removed quickly or immediately received.

Is there a problem with this approach? Can anyone suggest a better way to store this data?

+4
source share
1 answer

The problem with this approach is that it is extremely low level. It will be excruciatingly annoying to restore this information to the point where it makes sense from an application point of view.

For example, let's say you change the username. Are you using or are $setyou replacing a custom object? From the point of view of the application, this does not matter, but the oplog will look completely different. In addition, if you use a replacement, the information contained in oplog will not contain only changes, but only a new state. This means that the only way to understand what is actually happening is to do a full repetition of all operations (so that you have an old and new state).

, oplog , , , .

-, . , Unit of Work, , , ( ) . , , .

+1