@@ -382,9 +382,77 @@ get:
382382
383383---
384384
385+ # ## 🔗 Working with Related Data (Client-Side Joins)
386+
387+ Your API provides all the data you need - it's up to the client to decide how to combine it. This approach gives you maximum flexibility and control.
388+
389+ **Current approach:** Fetch related data in separate requests and combine on the client side.
390+
391+ # ### Quick Example: Get User with Posts
392+
393+ ` ` ` javascript
394+ // 1. Fetch user
395+ const user = await fetch('/api.php?action=read&table=users&id=123')
396+ .then(r => r.json());
397+
398+ // 2. Fetch user's posts
399+ const posts = await fetch('/api.php?action=list&table=posts&filter=user_id:123')
400+ .then(r => r.json());
401+
402+ // 3. Combine however you want
403+ const userData = {
404+ ...user,
405+ posts: posts.data
406+ };
407+ ` ` `
408+
409+ # ### Optimization: Use IN Operator for Batch Fetching
410+
411+ ` ` ` javascript
412+ // Get multiple related records in one request
413+ const postIds = '1|2|3|4|5'; // IDs from previous query
414+ const comments = await fetch(
415+ ` /api.php?action=list&table=comments&filter=post_id:in:${postIds}`
416+ ).then(r => r.json());
417+
418+ // Group by post_id on client
419+ const commentsByPost = comments.data.reduce((acc, comment) => {
420+ acc[comment.post_id] = acc[comment.post_id] || [];
421+ acc[comment.post_id].push(comment);
422+ return acc;
423+ }, {});
424+ ```
425+
426+ #### Parallel Fetching for Performance
427+
428+ ``` javascript
429+ // Fetch multiple resources simultaneously
430+ const [user , posts , comments ] = await Promise .all ([
431+ fetch (' /api.php?action=read&table=users&id=123' ).then (r => r .json ()),
432+ fetch (' /api.php?action=list&table=posts&filter=user_id:123' ).then (r => r .json ()),
433+ fetch (' /api.php?action=list&table=comments&filter=user_id:123' ).then (r => r .json ())
434+ ]);
435+
436+ // All requests happen at once - much faster!
437+ ```
438+
439+ 📖 ** [ See complete client-side join examples →] ( docs/CLIENT_SIDE_JOINS.md ) **
440+
441+ ** Why this approach?**
442+ - ✅ Client decides what data to fetch and when
443+ - ✅ Easy to optimize with caching and parallel requests
444+ - ✅ Different clients can have different data needs
445+ - ✅ Standard REST API practice
446+ - ✅ No server-side complexity for joins
447+
448+ ** Future:** Auto-join/expand features may be added based on user demand.
449+
450+ ---
451+
385452## 🗺️ Roadmap
386453
387- - Relations / Linked Data (auto-join, populate, or expand related records)
454+ - ** Client-side joins** ✅ (Current - simple and flexible!)
455+ - Relations / Linked Data (auto-join, populate, or expand related records) - * Future, based on demand*
388456- API Versioning (when needed)
389457- OAuth/SSO (if targeting SaaS/public)
390458- More DB support (Postgres, SQLite, etc.)
0 commit comments