cindel 0.5.2
cindel: ^0.5.2 copied to clipboard
Ultra-fast, lightweight NoSQL local database for Flutter and Dart apps, powered by a compact Rust native core.
example/README.md
Cindel example #
Add Cindel, the Flutter native libraries package, and the generator to your app:
dependencies:
cindel: ^0.5.2
cindel_flutter_libs: ^0.5.2
dev_dependencies:
build_runner: ^2.15.0
cindel_generator: ^0.5.2
Define a model and generate its schema:
import 'package:cindel/cindel.dart';
part 'user.g.dart';
@Collection(name: 'users')
class User {
Id id = autoIncrement;
@index
late String email;
late String name;
}
Use the generated schema and typed collection API:
import 'package:cindel/cindel.dart';
import 'user.dart';
Future<void> main() async {
final db = await Cindel.open(
directory: 'app_data',
schemas: [UserSchema],
);
final user = User()
..email = 'jhon@example.com'
..name = 'Jhon Doe';
await db.users.put(user);
final matches = await db.users
.where()
.emailEqualTo('jhon@example.com')
.findAll();
print('Found ${matches.length} user(s).');
await db.close();
}
Generate the code before running the app:
dart run build_runner build --delete-conflicting-outputs