π§ db.cms β CMS Utilities
A collection of helpers designed for content-driven and CMS-based systems.
The cms module provides high-level CMS utilities for HBH-DBMS, focusing on content fetching, content lookup, and ID handling. It integrates multi-threaded scanning, pagination-safe traversal, and indexed lookup.
π Designed for CMS, dashboards, and large-scale content processing. π Supports product-scoped content fetchers and ID-based direct content access. π Optimized for multi-threaded content scanning using workers.
π₯οΈ fetchcontent (Product-Specific Content Fetchers)
fetchcontent provides asynchronous content fetching functions per product. Each function returns content in paginated chunks.
1db.cms.fetchcontent.HBHCodes2db.cms.fetchcontent.HBHTube3db.cms.fetchcontent.CodeBuddy
Example Usage
1const fetchNext = db.cms.fetchcontent.HBHCodes;3// Fetch next batch of content4const contents = await fetchNext();5console.log(contents);
Behavior
- Tracks internal pagination: userPage, channelPage, contentPage.
- Auto-advances pages when current batch is empty.
- Can resume from a given pagination index:
1await fetchNext({ user: 2, channel: 1, content: 5 });
- Designed for CMS batch processing with large datasets.
π findcontent(targetID, { productName })
Finds content by ID using indexed IDManager lookup.
1const content = await db.cms.findcontent('content-id-123', { productName: 'CodeBuddy' });
Response
1{2 success: true,3 data: {4 user: "alice@example.com",5 channel: "Channel1",6 content: { ... }7 }8}
Notes
- Uses
IDManagerfor efficient indexed resolution. - Returns
nullif content is not found. - Avoids filesystem-wide traversal when possible.
π findchannel(targetChannel, { productName })
Finds channel info by name using ChannelManager.
1const channel = await db.cms.findchannel('Channel1', { productName: 'CodeBuddy' });
Response
1{2 success: true,3 data: {4 user: "alice@example.com",5 channel: "Channel1"6 }7}
Notes
- Channel names are normalized internally.
- Stops on first match for efficiency.
- Uses listall traversal internally only if needed.
π getcontent({ page, limit, ProductName, username })
Fetches content in paginated form for a given product and user.
1const pageData = await db.cms.getcontent({2 page: 1,3 limit: 50,4 ProductName: 'CodeBuddy',5 username: 'alice@example.com'6});
Notes
- Pagination-safe: Supports
pageandlimit. - Designed for UI dashboards, CMS listing, and admin views.
π handleid(ids, ProductName)
Fetches content directly via content IDs. Supports single ID or array of IDs.
1const result = await db.cms.handleid('D9.x.a.h', 'CodeBuddy');2const batch = await db.cms.handleid(['D9.x.a.h','D9.x.a.$'], 'CodeBuddy');
Behavior
- Uses ID-level parsing to determine hierarchy:
1root β user β channel β content
- Supports wildcard
$to fetch all content under a channel. - Throws structured errors via
IDProcessingErrorfor invalid IDs. - Returns
successanddatafields for matched content.
Example Response
1{2 success: true,3 data: {4 id: "D9.x.a.h",5 content: { title: "Hello World", ... },6 userName: "alice@example.com",7 channelName: "Channel1"8 }9}
π οΈ Worker-Based Content Scanning
The contentFinder function is an internal multi-threaded utility for CMS products.
Features
- Uses worker threads to scan directories concurrently.
- Tracks total content files and progress.
- Supports pause/resume events during scanning.
- Can stop early if a target content ID or channel is found.
- Writes output optionally to JSON for external processing.
Parameters
| Option | Type | Description |
|---|---|---|
ProductName |
string | Name of the product to scan |
find |
string | Target content ID(s) to search |
findChannel |
string | Target channel name to search |
OutputDir |
string | Directory to store output JSON |
WantOutput |
boolean | If true, writes results to file |
logs |
boolean | If true, logs progress info |
onProgress |
function | Callback on partial results or progress updates |
Example Usage
1await contentFinder({2 ProductName: 'CodeBuddy',3 WantOutput: true,4 find: 'D9.x.a.h',5 logs: true,6 onProgress: (data) => console.log('Progress:', data)7});
π§ Design Philosophy
β Product-scoped fetchers (fetchcontent) for CMS batch operations
β Direct content lookup (findcontent, handleid) using indexed resolution
β Worker-based multi-threaded scanning for large-scale content directories
β Safe pagination-based traversal, avoids full filesystem blocking
β Deterministic and recoverable: all fetches and searches are repeatable
If you want, I can now generate a full βCMS Referenceβ document with methods, parameters, examples, and detailed worker explanations in markdown just like the listall/findall documentation you shared. It would be ready for your docs site.
Do you want me to do that next?