Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #50 (Handle Deleted documents (Good First Issue)) #80

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kuldeep27396
Copy link

Description

This PR implements proper handling of deleted documents in MongoDB Change Data Capture (CDC). Previously, the system only handled insert and update operations while skipping delete operations. The implementation now properly captures and processes delete operations in the CDC stream, including metadata such as deletion timestamp and namespace information.

Fixes #50 (Handle Deleted documents (Good First Issue))

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

NA

Screenshots or Recordings

N/A - Backend changes only

Related PR's:

#51

Key Changes:

  1. Enhanced CDCDocument struct to include:
    • DocumentKey field for tracking deleted documents
    • Namespace information (DB and Collection)
  2. Implemented delete operation handling
  3. Added proper timestamp tracking for deletions
  4. Maintained existing behavior for insert/update operations

Copy link
Collaborator

@hash-data hash-data left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks For PR!
Some Comments

var documentToProcess map[string]any
switch record.OperationType {
case "delete":
documentToProcess = map[string]any{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document to process will only contain id (id of deleted object) in case of delete.


if documentToProcess != nil {
handleObjectID(documentToProcess)
rawRecord := types.CreateRawRecord(utils.GetKeysHash(documentToProcess, constants.MongoPrimaryID), documentToProcess, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, the last argument of CreateRawRecord takes the delete timestamp which can be taken from CDC delete metadata.

@shubham19may
Copy link
Contributor

@kuldeep27396 can you please update here?
We need to merge the PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle Deleted documents (Good First Issue)
3 participants