advancedTop 30 Scenario-Based Questions
How would you design a document approval workflow using MongoDB and Redis?
Workflow design: 1) MongoDB schema: Document {_id, title, content, status: DRAFT|PENDING|APPROVED|REJECTED, submitterId, approverId, comments:[...], history:[{status, changedBy, changedAt}], version:1}. 2) State machine: only valid transitions allowed. MongoDB document update with state validation. 3) Redis for pending approvals: ZADD pending:approvals {timestamp} {documentId}. Approver views: ZRA
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response