Overview
The Ziet Database provides persistent storage for your applications. Unlike Memory (which is scoped to a single agent run), Database stores data permanently across all runs.Database vs Memory
| Feature | Database | Memory |
|---|---|---|
| Scope | Global (all runs, agents, endpoints) | Per agent run |
| Persistence | Permanent | Temporary (cleared after run) |
| Use case | User data, products, orders | Intermediate results, agent context |
| Access | Actions, Agents, Endpoints | Actions, Agents only |
| Query | SQL-like queries | Key-value lookup |
- User accounts and profiles
- Products, orders, transactions
- Application state
- Data that needs to persist forever
- Intermediate action results
- Agent workflow context
- Temporary data during execution
Basic Operations
Insert
Add new records:Query
Fetch records:Update
Modify existing records:Delete
Remove records:Querying Data
Where Clauses
Filter records:Multiple Conditions
Chainwhere clauses:
Sorting
Order results:Limiting and Pagination
Counting
Using in Actions
Using in Agents
Using in Endpoints
Complete Example: E-commerce
Schema Management
Tables are Auto-Created
No need to define schemas - tables are created automatically on first insert:Built-in Fields
Every table automatically gets:id- Unique identifier (auto-generated)created_at- Timestamp of creationupdated_at- Timestamp of last update
Field Types
Ziet automatically infers field types:Relationships
One-to-Many
Many-to-Many
Use a join table:Best Practices
Use Database for permanent data
Use Database for permanent data
Use Memory for temporary data
Use Memory for temporary data
Index frequently queried fields
Index frequently queried fields
Query by common fields:
Use transactions for related operations
Use transactions for related operations
Store relationships explicitly
Store relationships explicitly
Limitations
Current limitations:
- No JOIN queries (fetch related data separately)
- No transactions yet (coming soon)
- No migrations (tables auto-created)
- Max 10,000 records per query