#[entity]Expand description
Author a typed record with named fields, a supplied scalar key and indexes.
Each field has an associated name constant, e.g. User::NAME for name.
Field types follow the implemented ic_db::FieldType contract, with explicit
bounds for variable-size values. Secondary indexes admit supported ordered
scalar fields and unit enums, including optional forms. Optional unique indexes require
present_only, omitting a row when any optional key component is absent. Unsupported shapes
refuse explicitly; this is not a retirement of the broader planned type surface.
Entity names default to the type name; name = "StableName" overrides it.
A nonunique single-component index can name a required indexable scalar
in a required record, e.g. index(field = "labels.text").
Index names default to comma-separated ordered fields; name overrides them.
A unique index on User(issuer, subject) generates UserByIssuerAndSubject
with named fields for session.get_unique(&key). A sparse unique key takes
the present component types. Equivalent unique indexes share a key type.
Required or optional supported key fields may declare references(entity = "path::Target");
scalar references select the sole eligible leading index, or use index = "name".
List references maintain their own reverse entries and accept a combined bound of 32 items
per entity. Use max_row_bytes to set this entity’s encoded row budget (default 4096, maximum 32768).
None has no target; every Some(id) requires that target in the final batch state.
entity = "path::Target" lets Rust resolve an entity type (including imports
and Self) to its logical identity. Numeric authoring IDs are unsupported.
With the host-only ic-db/build feature, declarations also register their
full Rust paths for second-stage schema assembly.
Fields may declare default = LITERAL for integers, Bool, bounded Text and Blob.
Blob defaults use Rust byte strings, e.g. default = b"\x00\xff", never text/hex coercion.
Entity::insert() builds typed omission-aware input for Batch::insert_input;
explicit optional None is never replaced by a default. Primary-key and nested
record defaults are not implemented. Defaults never run on decode/replacement.
Required Timestamp fields and their scalar newtypes may declare managed = "created_at" or
managed = "updated_at", once per role. These fields have no insert setters;
one batch captures one operation time for all managed fields.