|
| 1 | +# Examples |
| 2 | + |
| 3 | +This directory contains practical examples demonstrating how to use JsonFileCRUD in different scenarios. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +To run any example: |
| 8 | + |
| 9 | +```bash |
| 10 | +cd examples |
| 11 | +node <example-name>.js |
| 12 | +``` |
| 13 | + |
| 14 | +## Available Examples |
| 15 | + |
| 16 | +### 1. `basic-usage.js` - Basic CRUD Operations |
| 17 | + |
| 18 | +Learn the fundamentals of JsonFileCRUD: |
| 19 | + |
| 20 | +- Creating items |
| 21 | +- Reading all items |
| 22 | +- Finding items by ID |
| 23 | +- Updating items |
| 24 | +- Deleting items |
| 25 | +- Counting items |
| 26 | + |
| 27 | +**Run:** `node basic-usage.js` |
| 28 | + |
| 29 | +### 2. `advanced-usage.js` - Advanced Features |
| 30 | + |
| 31 | +Explore advanced capabilities: |
| 32 | + |
| 33 | +- Concurrent operations (automatic queuing) |
| 34 | +- Custom ID fields |
| 35 | +- Advanced filtering with `findBy()` |
| 36 | +- Batch operations |
| 37 | +- Error handling patterns |
| 38 | + |
| 39 | +**Run:** `node advanced-usage.js` |
| 40 | + |
| 41 | +### 3. `user-management.js` - Real-World Application |
| 42 | + |
| 43 | +See how to build a complete user management system: |
| 44 | + |
| 45 | +- User registration |
| 46 | +- Profile management |
| 47 | +- Role-based access |
| 48 | +- Soft deletion (deactivation) |
| 49 | +- Advanced queries |
| 50 | + |
| 51 | +**Run:** `node user-management.js` |
| 52 | + |
| 53 | +## Data Files |
| 54 | + |
| 55 | +Examples will create JSON files in the `data/` directory: |
| 56 | + |
| 57 | +- `users.json` - Basic usage data |
| 58 | +- `products.json` - Advanced usage data |
| 59 | +- `users-system.json` - User management data |
| 60 | + |
| 61 | +## Cleanup |
| 62 | + |
| 63 | +To clean up example data files: |
| 64 | + |
| 65 | +```bash |
| 66 | +rm -rf examples/data/*.json |
| 67 | +``` |
| 68 | + |
| 69 | +## Tips |
| 70 | + |
| 71 | +1. **Start with basic-usage.js** to understand the fundamentals |
| 72 | +2. **Check the data files** after running examples to see the JSON structure |
| 73 | +3. **Modify the examples** to experiment with your own data |
| 74 | +4. **Use the patterns** from these examples in your own projects |
| 75 | + |
| 76 | +## Next Steps |
| 77 | + |
| 78 | +After running the examples: |
| 79 | + |
| 80 | +1. Read the [main README](../README.md) for complete API documentation |
| 81 | +2. Check the [test files](../test/) for more usage patterns |
| 82 | +3. Start building your own application! |
0 commit comments