You are asked to implement a data storage system that supports basic operations, filtering, and "point-in-time" recovery (backups).
Level 1: Basic Storage (CRUD)
The goal is to manage records with multiple fields.
SET_OR_INC(key, field, value): If the field is a string, update it. If it's an integer, increment it.
GET(key, field): Basic retrieval.
DELETE(key, field): Remove a specific field or the entire key if no fields remain.
Level 2: Scanning & Filtering (The "Fetch" Level)
This level tests how you iterate over your data.
FETCH(field, value): Scan all records and return those that match.
The Catch: Usually, the output must be formatted as a string (e.g., "field1(val1), field2(val2)") and the results must be sorted alphabetically by the key.
Level 3: Advanced Filtering or TTL (Time-To-Live)
The final level usually adds one of two "Industry" constraints:
Option A (TTL): Every SET operation can include a ttl (Time-To-Live). If you GET or FETCH after the time has expired, the record must behave as if it was deleted.
Option B (Multi-field Filtering): Instead of matching one field, you might be asked to FETCH based on a prefix or a range of values (e.g., value > 100), requiring more complex iteration logic.
Level 4: Point-in-Time Snapshots (The "Backup" Level)
This is where the state management becomes tricky.
BACKUP(): Capture the state and return a backupId.
RESTORE(backupId): The database must instantly revert.
Implementation Tip: If you use a simple deepCopy(), you might fail the hidden performance tests for large datasets. High-performing solutions often use versioned maps or a Copy-on-Write strategy.
This description is from gemini but the problem was something like this only
I could not pass all test cases for level 4
scored 510/600
Platform - codesignal