chiffondb_generator
Code generator for ChiffonDB Dart annotations.
Generates type-safe ChiffonStore extensions and JSON utilities from classes annotated
with @NodeType and @EdgeType.
Installation
Add to your pubspec.yaml:
dependencies:
chiffondb: ^0.1.0
dev_dependencies:
chiffondb_generator: ^0.1.0
build_runner: ^2.4.0
Usage
1. Annotate your classes
import 'package:chiffondb/chiffondb.dart';
part 'my_schema.chiffondb_store.dart';
@NodeType()
class Person {
@Id()
final String id;
final String name;
final int age;
const Person({required this.id, required this.name, required this.age});
}
@EdgeType()
class Knows {
@FromNode()
final Person from;
@ToNode()
final Person to;
final DateTime since;
const Knows({required this.from, required this.to, required this.since});
}
2. Run the code generator
dart run build_runner build
This produces my_schema.chiffondb_store.dart containing:
- A
ChiffonStoreclass that wraps aConnectionand exposesapplyAllSchemas(). - Per-type schema DSL constants (
$PersonSchemaDsl,$KnowsSchemaDsl, …). - Internal JSON encode/decode helpers.
3. Apply schemas
final store = ChiffonStore(connection);
await store.applyAllSchemas();
License
Apache 2.0 — see LICENSE.
Author
SUZUKI Tetsuya tetsuya.suzuki@gmail.com