Expand description
Ergonomic data creation utilities.
This module provides multiple ways to create data for insert/update operations, from simple struct-based approaches to flexible builders.
§Approaches
§1. Struct-Based (Recommended for simple creates)
ⓘ
// Generated struct with required/optional fields
let user = client.user().create(UserCreate {
email: "bob@example.com".into(),
name: Some("Bob".into()),
..Default::default()
}).exec().await?;§2. Builder Pattern (For complex creates with relations)
ⓘ
let user = client.user()
.create_with(|b| b
.email("bob@example.com")
.name("Bob")
.posts(vec![
PostCreate { title: "Hello".into(), ..Default::default() }
])
)
.exec().await?;§3. Macro (Ultra-concise)
ⓘ
let user = client.user().create(data! {
email: "bob@example.com",
name: "Bob",
}).exec().await?;§4. From tuples (Quick and dirty)
ⓘ
// For models with few required fields
let user = client.user().create(("bob@example.com", "Bob")).exec().await?;Structs§
- Batch
Create - Batch create helper for creating multiple records.
- Connect
Data - Data for connecting to an existing record.
- Data
Builder - A flexible data builder for create/update operations.
Enums§
- Field
Value - A field value that can be set in create/update operations.
Traits§
- Create
Data - Trait for types that can be used as create data.
- Into
Data - Helper trait for converting to DataBuilder.
- Typed
Create Builder - Builder for creating records with a fluent API.
- Typed
Update Builder - Builder for updating records with a fluent API.
- Update
Data - Trait for types that can be used as update data.