Derive Macro spacetimedb_bindings_macro::TableType

source ·
#[derive(TableType)]
{
    // Attributes available to this derive:
    #[sats]
    #[unique]
    #[autoinc]
    #[primarykey]
}
Expand description

Generates code for treating this type as a table.

Among other things, this derives Serialize, Deserialize, SpacetimeType, and TableType for our type.

A table type must be a struct, whose fields may be annotated with the following attributes:

  • #[autoinc]

    Creates a database sequence.

    When a row is inserted with the annotated field set to 0 (zero), the sequence is incremented, and this value is used instead. Can only be used on numeric types and may be combined with indexes.

    Note that using #[autoinc] on a field does not also imply #[primarykey] or #[unique]. If those semantics are desired, those attributes should also be used.

  • #[unique]

    Creates an index and unique constraint for the annotated field.

  • #[primarykey]

    Similar to #[unique], but generates additional CRUD methods.