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

[be] audit logs #66

Open
HyuOniichan opened this issue Dec 13, 2024 · 0 comments
Open

[be] audit logs #66

HyuOniichan opened this issue Dec 13, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request question Further information is requested

Comments

@HyuOniichan
Copy link
Owner

Audit Logs

Audit logging is a practice where every user action (such as delete, restore, or modify) is recorded in a separate audit log collection or table. This is useful for:

Debugging: Identify why certain data was deleted or restored.
Accountability: Determine which user performed an action and when.
Regulatory Compliance: Some laws (e.g., HIPAA for healthcare) require records of data changes.
Example Audit Log Schema:

{
  _id: "log12345",
  action: "delete",          // Action type: delete, restore, etc.
  user_id: "user123",        // Who performed the action
  resource_id: "course123",  // The affected resource
  timestamp: "2024-12-13T10:00:00Z",
  metadata: {                // Additional details
    course_title: "Course Example"
  }
}

Audit Example in Practice:
When a course is soft-deleted, an audit log entry is created:

// On delete action:
await AuditLog.create({
  action: "delete",
  user_id: currentUser.id,
  resource_id: courseId,
  timestamp: new Date(),
  metadata: { course_title: "Course Example" },
});

(Explore this knowledge by chance when playing with ChatGpt 😃 )

@HyuOniichan HyuOniichan added documentation Improvements or additions to documentation enhancement New feature or request question Further information is requested labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant