Cindel generates typed collection accessors directly on theDocumentation 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.
CindelDatabase handle so your application code never has to deal with string collection names, raw documents, or id bookkeeping. After running build_runner for a User model you get a db.users getter that exposes put, get, delete, and their bulk counterparts — all fully typed, all backed by the same efficient binary storage used internally by Cindel’s query engine.
Accessing Generated Collections
The generator emits a Dart extension onCindelDatabase for each collection you define. The extension getter name is the lower-camel-case plural of your collection’s stored name:
XyzSchema to Cindel.open before using a collection getter — the database needs to register the schema to serve queries and id allocation.
Writing a Single Object — put
put(object) stores one typed object. If the object’s dbId is autoIncrement, Cindel allocates the next id from the native engine and writes it back to the field before the object is stored, so the same instance reflects the assigned id after await:
Reading a Single Object — get
get(id) returns the typed object stored under id, or null if no document exists:
Deleting a Single Object — delete
delete(id) removes the document stored under id. If no document exists for that id the call is a no-op:
Bulk Writes — putAll
putAll stores multiple objects atomically. Input order is preserved and auto-increment ids are allocated before storage:
Bulk Reads — getAll
getAll([ids]) returns typed objects in the same order as the input id list. Missing ids produce null at that position:
Bulk Deletes — deleteAll
deleteAll([ids]) removes every document in the id list atomically. Passing an empty list is a no-op:
Unique-Replace Upsert Helpers
When a field is annotated with@Index(unique: true, replace: true), the generator produces a putByFieldName(object) helper that performs a natural-key upsert. Before writing, it looks up any existing document that holds the same indexed value and reuses its id, so you never accidentally create duplicate rows:
username == 'ada', putByUsername sets account.dbId to that document’s id before calling put, so the write replaces the existing document rather than inserting a duplicate.
Transactions and Writes
Single writes (oneput or delete call outside an explicit transaction) are automatically wrapped in an internal write transaction by Cindel. When you need to write to multiple collections atomically, use an explicit writeTxn block — see Transactions for the full story: