Documentation 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.
CindelBackup provides a full-database export and import API that streams a typed archive to or from any Dart StreamConsumer<List<int>> or Stream<List<int>>. The archive format is JSONL — one JSON object per line — optionally compressed with gzip. An FNV-1a checksum written into the footer is verified on every import, making it safe to transport archives across networks or store them at rest and detect corruption before restoring.
Archive Format
After decompression, a Cindel archive is a sequence of UTF-8 JSONL records:| Record type | Contents |
|---|---|
header | Format identifier, version, backend name, creation timestamp, and migration version |
schema | Collection name and schema version, one per exported collection |
doc | Collection name, document id, and the full document map, one per object |
footer | Total document count and FNV-1a checksum over all preceding records |
importDatabase recomputes the checksum while reading and throws a StateError if the value does not match the footer.
Exporting a Database
CallCindelBackup.exportDatabase with the open database handle, a list of CindelBackupCollection wrappers, and any StreamConsumer<List<int>> as the output sink. The method returns a CindelBackupReport when the stream is fully drained:
CindelBackupCollection
Wrap each generated schema with CindelBackupCollection(schema) to include it in the archive. The schema must match the one used to open the database:
Compression
On native Dart platforms,CindelBackup defaults to CindelBackupCompression.gzip. On Web it defaults to CindelBackupCompression.none. You can override the default by passing the compression parameter explicitly:
CindelBackupReport
Both exportDatabase and importDatabase return a CindelBackupReport:
| Field | Description |
|---|---|
documents | Number of document records in the archive |
uncompressedBytes | Size of the JSONL byte stream before compression |
archiveBytes | Size read from or written to the caller-provided stream |
checksum | FNV-1a checksum of non-footer JSONL records |
compression | Compression mode used for the stream |
Importing a Database
CallCindelBackup.importDatabase with an empty database opened with the matching schemas and a Stream<List<int>> pointing at the archive:
importDatabase writes that version into the restored database so Cindel does not re-run migrations on next open.
Progress Callbacks
Both export and import accept an optionalonProgress callback. It receives a CindelBackupProgress snapshot with the current phase (export or import), the collection name being processed, and the total document count so far:
Paged ID Scans for Custom Tooling
Lower-level tooling that needs to iterate over a large collection without materializing everything at once can usedocumentIdsPage. It returns a bounded, ascending page of document ids without fetching the documents themselves:
limit ids that are strictly greater than afterId. When the returned list is empty, you have reached the end of the collection. This pattern works on SQLite native, MDBX, and Web SQLite backends.
documentIds() (without the page parameters) is also available when loading the full id list is acceptable for the collection size you are working with.