Skip to content

Commit

Permalink
Initial update for v4 in quickstart guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Clauss committed Mar 7, 2024
1 parent 3137cde commit 6f4441d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 38 deletions.
24 changes: 5 additions & 19 deletions docs/docs/de/tutorials/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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
});
Expand Down
24 changes: 5 additions & 19 deletions docs/docs/tutorials/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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
});
Expand Down

0 comments on commit 6f4441d

Please sign in to comment.