Zero-DDL Dynamic Models & Auto-CRUD
This chapter covers:
- Understand Zero-DDL schema-free storage philosophy;
- Use
RecordStoreAPIs for creating, reading, updating, and querying records; - Understand auto-generated RESTful Auto-CRUD endpoints;
- Choose between Code-First ORM and Zero-DDL Dynamic Models.
1. Zero-DDL Philosophy
Section titled “1. Zero-DDL Philosophy”Unlike traditional frameworks where every new table requires SQL DDL migrations, Foundry allows dynamic model definition via the Admin Console with instant REST API generation under /api/v1/s/{subsystem}/{model}:
use foundry::prelude::*;use serde_json::json;
// Create record in domain servicelet record = state.db.records().create( &ctx.system_slug, "feedbacks", json!({ "score": 5, "comment": "Fast shipping!" })).await?;2. Auto-CRUD Endpoints
Section titled “2. Auto-CRUD Endpoints”| Method | Endpoint | Description |
|---|---|---|
GET |
/api/v1/s/{subsystem}/{model} |
Paginated list with search |
POST |
/api/v1/s/{subsystem}/{model} |
Create record |
GET |
/api/v1/s/{subsystem}/{model}/{id} |
Get record |
PUT |
/api/v1/s/{subsystem}/{model}/{id} |
Update record |
DELETE |
/api/v1/s/{subsystem}/{model}/{id} |
Delete record |
Next chapter: Authentication & Hierarchical RBAC