From 6f4441d6bdfbe5b46ff1d3d00ac4d7fcde9eaf24 Mon Sep 17 00:00:00 2001 From: Martin Clauss Date: Thu, 7 Mar 2024 21:38:21 +0100 Subject: [PATCH 1/2] Initial update for v4 in quickstart guide --- docs/docs/de/tutorials/quickstart.md | 24 +++++------------------- docs/docs/tutorials/quickstart.md | 24 +++++------------------- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/docs/docs/de/tutorials/quickstart.md b/docs/docs/de/tutorials/quickstart.md index 673165acc..c0cdde976 100644 --- a/docs/docs/de/tutorials/quickstart.md +++ b/docs/docs/de/tutorials/quickstart.md @@ -13,8 +13,7 @@ Dieser Schnellstart wird wenig um den heißen Brei herumreden und direkt mit dem Bevor es losgeht, müssen wir ein paar Pakete zur `pubspec.yaml` hinzufügen. Damit es schneller geht lassen wir pub das für uns erledigen. ```bash -flutter pub add isar isar_flutter_libs -flutter pub add -d isar_generator build_runner +dart pub add isar:^4.0.0-dev.15 isar_flutter_libs:^4.0.0-dev.15 --hosted-url=https://isar-community.dev ``` ## 2. Klassen annotieren @@ -26,7 +25,7 @@ part 'user.g.dart'; @collection class User { - Id id = Isar.autoIncrement; // Für auto-increment kannst du auch id = null zuweisen + late int id; // Für auto-increment kannst du auch id = null zuweisen String? name; @@ -36,21 +35,7 @@ class User { IDs identifizieren Objekte in einer Collection eindeutig und erlauben es dir, sie später wiederzufinden. -## 3. Code-Generator ausführen - -Führe den folgenden Befehl aus, um den `build_runner` zu starten: - -``` -dart run build_runner build -``` - -Wenn du Flutter verwendest: - -``` -flutter pub run build_runner build -``` - -## 4. Isar-Instanz öffnen +## 3. Isar-Instanz öffnen Öffne eine neue Isar-Instanz und übergebe alle Collection-Schemata. Optional kannst du einen Instanznamen und ein Verzeichnis angeben. @@ -62,7 +47,7 @@ final isar = await Isar.open( ); ``` -## 5. Schreiben und lesen +## 4. Schreiben und lesen Wenn deine Instanz geöffnet ist, hast du Zugriff auf die Collections. @@ -72,6 +57,7 @@ Alle grundlegenden CRUD-Operationen sind über die `IsarCollection` verfügbar . final newUser = User()..name = 'Jane Doe'..age = 36; await isar.writeTxn(() async { + newUser.id = isar.users.autoIncrement(); await isar.users.put(newUser); // Einfügen & akualisieren }); diff --git a/docs/docs/tutorials/quickstart.md b/docs/docs/tutorials/quickstart.md index 90fabe376..37e4acc0b 100644 --- a/docs/docs/tutorials/quickstart.md +++ b/docs/docs/tutorials/quickstart.md @@ -13,8 +13,7 @@ We're going to be short on words and quick on code in this quickstart. Before the fun begins, we need to add a few packages to the `pubspec.yaml`. We can use pub to do the heavy lifting for us. ```bash -flutter pub add isar isar_flutter_libs path_provider -flutter pub add -d isar_generator build_runner +dart pub add isar:^4.0.0-dev.15 isar_flutter_libs:^4.0.0-dev.15 --hosted-url=https://isar-community.dev ``` ## 2. Annotate classes @@ -28,7 +27,7 @@ part 'user.g.dart'; @collection class User { - Id id = Isar.autoIncrement; // you can also use id = null to auto increment + late int id; String? name; @@ -38,21 +37,7 @@ class User { Ids uniquely identify objects in a collection and allow you to find them again later. -## 3. Run code generator - -Execute the following command to start the `build_runner`: - -``` -dart run build_runner build -``` - -If you are using Flutter, use the following: - -``` -flutter pub run build_runner build -``` - -## 4. Open Isar instance +## 3. Open Isar instance Open a new Isar instance and pass all of your collection schemas. Optionally you can specify an instance name and directory. @@ -64,7 +49,7 @@ final isar = await Isar.open( ); ``` -## 5. Write and read +## 4. Write and read Once your instance is open, you can start using the collections. @@ -74,6 +59,7 @@ All basic CRUD operations are available via the `IsarCollection`. final newUser = User()..name = 'Jane Doe'..age = 36; await isar.writeTxn(() async { + newUser.id = isar.users.autoIncrement(); await isar.users.put(newUser); // insert & update }); From b3171952f799ac556a3a4d5aa52dcc25fcebecdc Mon Sep 17 00:00:00 2001 From: Martin Clauss Date: Thu, 7 Mar 2024 21:53:34 +0100 Subject: [PATCH 2/2] v4 docs: Fix sample write/read code --- docs/docs/de/tutorials/quickstart.md | 6 +++--- docs/docs/tutorials/quickstart.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/de/tutorials/quickstart.md b/docs/docs/de/tutorials/quickstart.md index c0cdde976..3a775033b 100644 --- a/docs/docs/de/tutorials/quickstart.md +++ b/docs/docs/de/tutorials/quickstart.md @@ -25,7 +25,7 @@ part 'user.g.dart'; @collection class User { - late int id; // Für auto-increment kannst du auch id = null zuweisen + late int id; String? name; @@ -56,14 +56,14 @@ Alle grundlegenden CRUD-Operationen sind über die `IsarCollection` verfügbar . ```dart final newUser = User()..name = 'Jane Doe'..age = 36; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { newUser.id = isar.users.autoIncrement(); await isar.users.put(newUser); // Einfügen & akualisieren }); final existingUser = await isar.users.get(newUser.id); // Erhalten -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.users.delete(existingUser.id!); // Löschen }); ``` diff --git a/docs/docs/tutorials/quickstart.md b/docs/docs/tutorials/quickstart.md index 37e4acc0b..e0b970e50 100644 --- a/docs/docs/tutorials/quickstart.md +++ b/docs/docs/tutorials/quickstart.md @@ -58,14 +58,14 @@ All basic CRUD operations are available via the `IsarCollection`. ```dart final newUser = User()..name = 'Jane Doe'..age = 36; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { newUser.id = isar.users.autoIncrement(); await isar.users.put(newUser); // insert & update }); final existingUser = await isar.users.get(newUser.id); // get -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.users.delete(existingUser.id!); // delete }); ```