Code Generator for Couchbase Lite
Generates typed document model classes for cbl, giving you type-safe access to document properties with zero boilerplate.
Getting Started
Add the package as a dev dependency alongside build_runner:
dart pub add --dev cbl_generator build_runner
Define your document model:
import 'package:cbl/cbl.dart';
part 'user.cbl.type.g.dart';
@TypedDocument()
abstract class User with _$User {
factory User({
@DocumentId() String? id,
required String username,
required String email,
required DateTime createdAt,
}) = MutableUser;
}
Run the code generator:
dart run build_runner build
Use the generated classes:
final user = MutableUser(
username: 'alice',
email: 'alice@example.com',
createdAt: DateTime.now(),
);
await collection.saveTypedDocument(user).withConcurrencyControl();
Read the full documentation at cbl-dart.dev
Contributing
Pull requests are welcome. For major changes, please open an issue first. Read CONTRIBUTING to get started.
Disclaimer
This is not an official Couchbase product.