Skip to content

Commit 97eec6e

Browse files
authored
Merge pull request #23 from isar-community/v4docs
Initial update for v4 in quickstart guide
2 parents 3137cde + b317195 commit 97eec6e

File tree

2 files changed

+14
-42
lines changed

2 files changed

+14
-42
lines changed

docs/docs/de/tutorials/quickstart.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ Dieser Schnellstart wird wenig um den heißen Brei herumreden und direkt mit dem
1313
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.
1414

1515
```bash
16-
flutter pub add isar isar_flutter_libs
17-
flutter pub add -d isar_generator build_runner
16+
dart pub add isar:^4.0.0-dev.15 isar_flutter_libs:^4.0.0-dev.15 --hosted-url=https://isar-community.dev
1817
```
1918

2019
## 2. Klassen annotieren
@@ -26,7 +25,7 @@ part 'user.g.dart';
2625
2726
@collection
2827
class User {
29-
Id id = Isar.autoIncrement; // Für auto-increment kannst du auch id = null zuweisen
28+
late int id;
3029
3130
String? name;
3231
@@ -36,21 +35,7 @@ class User {
3635

3736
IDs identifizieren Objekte in einer Collection eindeutig und erlauben es dir, sie später wiederzufinden.
3837

39-
## 3. Code-Generator ausführen
40-
41-
Führe den folgenden Befehl aus, um den `build_runner` zu starten:
42-
43-
```
44-
dart run build_runner build
45-
```
46-
47-
Wenn du Flutter verwendest:
48-
49-
```
50-
flutter pub run build_runner build
51-
```
52-
53-
## 4. Isar-Instanz öffnen
38+
## 3. Isar-Instanz öffnen
5439

5540
Öffne eine neue Isar-Instanz und übergebe alle Collection-Schemata. Optional kannst du einen Instanznamen und ein Verzeichnis angeben.
5641

@@ -62,7 +47,7 @@ final isar = await Isar.open(
6247
);
6348
```
6449

65-
## 5. Schreiben und lesen
50+
## 4. Schreiben und lesen
6651

6752
Wenn deine Instanz geöffnet ist, hast du Zugriff auf die Collections.
6853

@@ -71,13 +56,14 @@ Alle grundlegenden CRUD-Operationen sind über die `IsarCollection` verfügbar .
7156
```dart
7257
final newUser = User()..name = 'Jane Doe'..age = 36;
7358
74-
await isar.writeTxn(() async {
59+
await isar.writeAsync((isar) async {
60+
newUser.id = isar.users.autoIncrement();
7561
await isar.users.put(newUser); // Einfügen & akualisieren
7662
});
7763
7864
final existingUser = await isar.users.get(newUser.id); // Erhalten
7965
80-
await isar.writeTxn(() async {
66+
await isar.writeAsync((isar) async {
8167
await isar.users.delete(existingUser.id!); // Löschen
8268
});
8369
```

docs/docs/tutorials/quickstart.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ We're going to be short on words and quick on code in this quickstart.
1313
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.
1414

1515
```bash
16-
flutter pub add isar isar_flutter_libs path_provider
17-
flutter pub add -d isar_generator build_runner
16+
dart pub add isar:^4.0.0-dev.15 isar_flutter_libs:^4.0.0-dev.15 --hosted-url=https://isar-community.dev
1817
```
1918

2019
## 2. Annotate classes
@@ -28,7 +27,7 @@ part 'user.g.dart';
2827
2928
@collection
3029
class User {
31-
Id id = Isar.autoIncrement; // you can also use id = null to auto increment
30+
late int id;
3231
3332
String? name;
3433
@@ -38,21 +37,7 @@ class User {
3837

3938
Ids uniquely identify objects in a collection and allow you to find them again later.
4039

41-
## 3. Run code generator
42-
43-
Execute the following command to start the `build_runner`:
44-
45-
```
46-
dart run build_runner build
47-
```
48-
49-
If you are using Flutter, use the following:
50-
51-
```
52-
flutter pub run build_runner build
53-
```
54-
55-
## 4. Open Isar instance
40+
## 3. Open Isar instance
5641

5742
Open a new Isar instance and pass all of your collection schemas. Optionally you can specify an instance name and directory.
5843

@@ -64,7 +49,7 @@ final isar = await Isar.open(
6449
);
6550
```
6651

67-
## 5. Write and read
52+
## 4. Write and read
6853

6954
Once your instance is open, you can start using the collections.
7055

@@ -73,13 +58,14 @@ All basic CRUD operations are available via the `IsarCollection`.
7358
```dart
7459
final newUser = User()..name = 'Jane Doe'..age = 36;
7560
76-
await isar.writeTxn(() async {
61+
await isar.writeAsync((isar) async {
62+
newUser.id = isar.users.autoIncrement();
7763
await isar.users.put(newUser); // insert & update
7864
});
7965
8066
final existingUser = await isar.users.get(newUser.id); // get
8167
82-
await isar.writeTxn(() async {
68+
await isar.writeAsync((isar) async {
8369
await isar.users.delete(existingUser.id!); // delete
8470
});
8571
```

0 commit comments

Comments
 (0)