Reputation: 5191
I am a newbie for MongoDB.
Please help me with the following query:
I am using oplogs for adding Triggers for MongoDB operation. On doing insert/update operations, I receive the complete information about all fields added/updated in the collection.
My problem is:
When I do delete operations in MongoDB, the oplog triggers received contains ONLY the object_id.
Can somebody please point out to some example where I can receive complete information in all fields - for the deleted row in the trigger.
Thanks
Upvotes: 2
Views: 1902
Reputation: 21692
You have to fetch that document by its ObjectID, which will not be possible on the current node you are tailing the oplog
from because by the time you have received the delete operation from the oplog
, the document is gone. Which I believe means you have two choices:
For number 2, the issue is having a delay that is long enough to guarantee that you can fetch the document and short enough to make sure you are getting an up to date version of the document. Unless you add versioning to the document as a check (which is then getting similar to option 1, you would likely want to update the version before deleting), this would have to be essentially an optimistic, best efforts solution.
Upvotes: 2