Cindel’s code generator emits oneDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/mainser/cindel/llms.txt
Use this file to discover all available pages before exploring further.
CindelCollectionSchema<T> instance per annotated collection class, together with the field, link, and composite-index metadata nested inside it. The runtime reads these schema objects at open time to register collections, validate migrations, and route serialization. Application code encounters them in two places: the schemas list passed to Cindel.open (e.g. [UserSchema, OrderSchema]) and the CindelBackupCollection(UserSchema) constructor used for backup and restore. You never construct these types manually — every instance is produced by the generator.
All four types described on this page are declared in
package:cindel/src/schema.dart and re-exported from package:cindel.CindelCollectionSchema<T>
Generated metadata for a single Cindel collection. The type parameterT is the Dart class the schema represents (e.g. CindelCollectionSchema<User>).
Declaration: final class CindelCollectionSchema<T>
Constructor parameters
The stored collection name — the string used in the native database, schemas, and migration contexts. Matches the
name argument of @Collection, or the lower-camel-case class name when no name was given.The Dart class name as written in source (e.g.
"User"). Used for diagnostic messages and migration introspection.The Dart field name that holds the document id (e.g.
"dbId"). The runtime uses this to read and write the id without going through the full document map.Metadata for every persisted field. The list is stored as an unmodifiable copy. See CindelFieldSchema below.
Metadata for every generated link and backlink field. The list is stored as an unmodifiable copy. See CindelLinkSchema below.
Metadata for every collection-level composite index. The list is stored as an unmodifiable copy. See CindelCompositeIndexSchema below.
Generated serializer — converts a
T instance into a Map<String, Object?> document. Used by the map-based backends and during backup export.Generated deserializer — converts a
Map<String, Object?> document back into a T instance. Used by the map-based backends and during backup import.Optional generated serializer — converts a
T instance into CindelBinaryDocumentBytes (a Uint8List). Provided when the generator emits a native binary fast path for this collection.Optional generated deserializer — converts
CindelBinaryDocumentBytes back into a T instance. Provided when the generator emits a native binary fast path for this collection.Optional generated accessor — reads the id field from a
T instance without constructing a full document map. Provided when the generator can emit it.Optional generated serializer — writes a
T instance into a CindelNativeDocumentWriter directly, bypassing an intermediate Map. Provided when the generator emits a native-writer fast path.Optional generated deserializer — reads a
T instance from a CindelNativeDocumentReader directly. Provided when the generator emits a native-reader fast path.Optional generated mutator — assigns a native auto-increment id back to a
T instance after a write. Provided when the generator can emit it.Optional generated callback — binds generated link fields to the database handle after an object is hydrated. Provided when the collection has links or backlinks.
Example
The generator produces a top-level constant for each collection. The snippet below shows the shape of a generated schema (simplified):Passing schemas to Cindel.open
Passing schemas to CindelBackupCollection
CindelFieldSchema
Generated metadata for a single persisted field within a collection. Declaration:final class CindelFieldSchema
The stored field name as it appears in documents and native indexes. Matches the Dart field name unless overridden with
@Name.The Dart type string as written by the analyzer (e.g.
"String", "int?", "List<String>"). Used for migration introspection and diagnostics.The schema-backed binary storage type used by generated native serializers.
null when no native binary path is available for this field.true when this field is the collection’s id field (i.e. it holds the Id / int document identifier).true when the field is annotated with @Index or @index.true when the index was declared with unique: true.true when the unique index was declared with replace: true. When set, conflicting writes replace the existing document instead of throwing.true when string index lookups are case-sensitive. Only meaningful for String fields.The storage strategy for this field’s index. See
CindelIndexType in the Annotations reference.Example
CindelLinkSchema
Generated metadata for a link (CindelLink<T> or CindelLinks<T>) or backlink (@Backlink) field.
Declaration: final class CindelLinkSchema
The persisted relation name used in the native link table. Derived from the Dart field name unless overridden with
@Name.The Dart field name as written in source (e.g.
"featuredArtists").The stored collection name of the collection this link points to.
true for CindelLinks<T> (to-many) fields; false for CindelLink<T> (to-one) fields.true when this schema entry describes a backlink (i.e. the field is annotated with @Backlink).For backlinks, the Dart field name of the forward link on the target collection that this backlink mirrors.
null for forward links.Example
CindelCompositeIndexSchema
Generated metadata for a collection-level composite index declared viaCompositeIndex in the @Collection annotation.
Declaration: final class CindelCompositeIndexSchema
The stable native index name generated by the code generator. This name is written to the native backend and must remain stable across re-generations for migrations to work correctly. The generator derives it deterministically from the collection name and field list.
The indexed field names in index order. The list is stored as an unmodifiable copy.
true when the composite index requires unique values across the combined key.true when a write conflicting with this unique composite index should replace the existing document.true when string field comparisons within the composite key are case-sensitive.