darudb_generator 1.1.0
darudb_generator: ^1.1.0 copied to clipboard
Generates the schema, the query builder and copyWith of a class annotated for DaruDB, with build_runner.
darudb_generator #
The code generator of DaruDB's Dart package. With build_runner, it writes for each class annotated @Collection() its schema constant, such as userSchema for User, the functions that write it as a record and read it from one, a query builder with a typed field for each field, a link type for queries through links, and a copyWith; and for each class annotated @Embedded() the same, for an embedded object.
dev_dependencies:
build_runner: ^2.10.0
darudb_generator: ^1.1.0
dart run build_runner build
On Dart 3.10, build_runner stops with 'dart compile' does not support build hooks: the newest build_runner that runs on it compiles the builders with dart compile, which Dart 3.10 refuses for a project whose packages have a build hook, as darudb has. Add --force-jit there, which compiles the builders as they run instead.
A class it reads has final fields of a type the database stores, bool, int, double, String, Uint8List, a List of those or of links, a Link to a collection or a class annotated @Embedded(), each nullable for an optional field, and an unnamed constructor that takes every field. A constructor parameter's default is the field's default in the schema. The darudb package documents the annotations.