Skip to content

Commit 4edd814

Browse files
committed
添加初始数据定义和元数据 API 结构,支持启动时加载默认记录
1 parent 3df3dea commit 4edd814

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

docs/spec/metadata-standard.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,26 @@ rules:
9898
compare_to: start_date
9999
```
100100
101+
#### Initial Data
102+
**Purpose**: Define seed data or default records to be loaded on startup.
103+
104+
**What you define**:
105+
- Target object
106+
- List of records to insert (auto-created if validation passes)
107+
108+
**Example**:
109+
```yaml
110+
# initial.data.yml
111+
object: User
112+
records:
113+
- name: Administrator
114+
email: admin@company.com
115+
role: admin
116+
- name: Guest
117+
email: guest@company.com
118+
role: read_only
119+
```
120+
101121
### 2. Business Logic Layer
102122
103123
#### [Hooks (Triggers)](./hook.md)
@@ -425,6 +445,35 @@ src/
425445
2. Deploy to ObjectOS runtime
426446
3. Monitor and iterate
427447

448+
## Metadata API & File Structure
449+
450+
ObjectQL provides a universal loader and generic API for all metadata types.
451+
452+
### File Naming Convention
453+
Metadata files are automatically loaded based on their extension. The `name` property in the file is used as the ID, or it is inferred from the filename (e.g. `my-list.view.yml` -> `my-list`).
454+
455+
| Type | Extension |
456+
|---|---|
457+
| Object | `*.object.yml` |
458+
| View | `*.view.yml` |
459+
| Form | `*.form.yml` |
460+
| Menu | `*.menu.yml` |
461+
| Report | `*.report.yml` |
462+
| Workflow | `*.workflow.yml` |
463+
| Permission | `*.permission.yml` |
464+
| Validation | `*.validation.yml` |
465+
| Initial Data | `*.data.yml` |
466+
467+
### Generic Metadata API
468+
All metadata types can be queried via the REST API:
469+
470+
- `GET /api/metadata/:type`
471+
- List all entries for a specific type (e.g. `/api/metadata/view`)
472+
- `GET /api/metadata/:type/:id`
473+
- Get the JSON content of a specific entry (e.g. `/api/metadata/view/task_list`)
474+
- `POST /api/metadata/:type/:id`
475+
- Update metadata content (if supported by storage)
476+
428477
## Why Metadata-Driven?
429478

430479
### Traditional Development

0 commit comments

Comments
 (0)