harndb 0.1.3 harndb: ^0.1.3 copied to clipboard
a simple key-value non-relational database engine for dart.
import 'package:flutter/material.dart';
import 'package:harndb/harndb.dart';
import 'package:harndb_example/data.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
db.initialize();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
void deleteCollections() async {
// final list = await db.listCollectionNames();
// list.forEach((element) {
// db.deleteCollection(element);
// print(element);
// });
}
void test() async {
User firstUser = User(id: HarnUtils.generateId(), name: "Andress", age: 33);
await users.insert(firstUser);
print(users.find());
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: [
Container(
height: 20,
),
ElevatedButton(onPressed: test, child: const Text("test")),
Container(
height: 20,
),
],
),
),
);
}
}