Skip to content

Commit

Permalink
Merge pull request isar-community#23 from isar-community/v4docs
Browse files Browse the repository at this point in the history
Initial update for v4 in quickstart guide
  • Loading branch information
mrclauss authored Mar 8, 2024
2 parents 3137cde + b317195 commit 97eec6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
28 changes: 7 additions & 21 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;
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 @@ -71,13 +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
});
```
Expand Down
28 changes: 7 additions & 21 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 @@ -73,13 +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
});
```
Expand Down

0 comments on commit 97eec6e

Please sign in to comment.