Skip to main content

Collection

Derive Macro Collection 

Source
#[derive(Collection)]
{
    // Attributes available to this derive:
    #[collection]
}
Expand description

Automatically derives the Collection trait implementation

§Usage

§Basic usage (using default collection name - auto pluralization)

ⓘ
#[derive(Collection, Serialize, Deserialize, Debug, Clone)]
struct User {
    id: String,
    name: String,
}
// Collection name will be "users" (automatically pluralized)

§Specifying a custom collection name

ⓘ
#[derive(Collection, Serialize, Deserialize, Debug, Clone)]
#[collection(name = "users")]
struct User {
    id: String,
    name: String,
}
// Collection name will be "users"