Files
base/example/hanzo_base_example.dart
zeekay 42fdfa209d Rename Dart package hanzo -> hanzo_base
pub.dev names 'hanzo' and 'base' are taken by unrelated packages;
'hanzo_base' is the correct available name. Renames the library
(lib/hanzo.dart -> lib/hanzo_base.dart), example, and test, and
fixes all package: imports, README, badge, and pubspec repository
to hanzo-dart/base. dart analyze --fatal-infos + dart test green;
pub publish --dry-run clean (0 warnings).
2026-07-03 14:33:01 -07:00

30 lines
853 B
Dart

import 'package:hanzo_base/hanzo_base.dart';
Future<void> main() async {
final base = HanzoBase('https://base.hanzo.ai');
// Authenticate against a Hanzo IAM-backed auth collection.
await base.collection('users').authWithPassword('[email protected]', 'secret');
// List records.
final page = await base.collection('posts').getList(
perPage: 20,
filter: base.filter('published = {:v}', {'v': true}),
sort: '-created',
);
for (final record in page.items) {
// ignore: avoid_print
print('${record.id}: ${record['title']}');
}
// Subscribe to realtime changes.
final unsubscribe = base.collection('posts').subscribe('*', (event) {
// ignore: avoid_print
print('${event.action}: ${event.record.id}');
});
// Later: stop listening and release resources.
unsubscribe();
base.close();
}