It demonstrates the implementation of MongoDB change streams and triggers to create an audit logging system for tracking changes to database collections.
-
Clone the repository
git clone https://github.com/sujeethshingade/mongodb-document-trigger.git cd mongodb-document-trigger
-
Install dependencies
npm install # or yarn install
-
Set up environment variables Create a
.env.local
file in the root directory with:MONGODB_URI=your_mongodb_connection_string
-
Run the development server
npm run dev # or yarn dev
-
Access the application Open http://localhost:3000 in your browser
-
Pre/Post Image Retention: Default retention period - 3 days (259,200 seconds)
-
Full Document: Captures the complete state of documents after changes
-
Document Preimage: Captures the document state before changes
-
Auto-resume: Automatically resumes change streams if interrupted
-
Event Ordering: Maintains consistent ordering of change events