△
DMCallv1
Projects
AI Models
Docs
Inventory
Rules
Backup
AI Logs
Workspaces
Rules
/ Database Conventions / Edit
Edit Rule
Rule Info
Title *
Slug
Category
Workflow
Coding
Deployment
Database
Ai Usage
Backup
General
Sort Order
Public (accessible without API key)
Content (Markdown)
Markdown Source
# Database Conventions ## MongoDB The primary database for all projects in this ecosystem is MongoDB 3.6.8. ### Collection Naming - Prefix all collections with the project identifier - DMCallv1 hub collections: `v1_{name}` (e.g., `v1_projects`) - Other projects: `{project}_{name}` (e.g., `extension2_emails`) ### Document Structure Every document should include: ```json { "_id": ObjectId, "slug": "human-readable-id", "created_at": UTCDateTime, "updated_at": UTCDateTime } ``` ### PHP Driver Usage (v1.19.3) ```php // Insert $collection->insertOne($data); // Find one $collection->findOne(['slug' => $slug]); // Update $collection->updateOne(['slug' => $slug], ['$set' => $updates]); // Upsert $collection->updateOne(['slug' => $slug], ['$set' => $data], ['upsert' => true]); // Delete $collection->deleteOne(['slug' => $slug]); ``` ### ObjectId Handling Always convert `_id` to string for JSON responses: ```php $arr = json_decode(json_encode($doc), true); if (isset($arr['_id']['$oid'])) $arr['_id'] = $arr['_id']['$oid']; ``` ## MySQL Some projects may use MySQL. Connection via PDO or mysqli. Always use prepared statements.
Preview
Save Changes
Cancel