From add19400fa9b2b557afde0474ce2c85b3ca21e8d Mon Sep 17 00:00:00 2001 From: Martin Clauss Date: Sat, 9 Mar 2024 19:01:09 +0100 Subject: [PATCH] Update docs regarding IDs and transactions --- docs/docs/crud.md | 17 +++++++++-------- docs/docs/de/crud.md | 17 +++++++++-------- docs/docs/de/indexes.md | 14 +++++++------- docs/docs/de/links.md | 12 +++++++----- docs/docs/de/queries.md | 12 ++++++------ docs/docs/de/recipes/data_migration.md | 4 ++-- docs/docs/de/recipes/full_text_search.md | 6 +++--- docs/docs/de/schema.md | 12 ++++++------ docs/docs/de/transactions.md | 14 +++++++------- docs/docs/es/crud.md | 17 +++++++++-------- docs/docs/es/indexes.md | 14 +++++++------- docs/docs/es/links.md | 12 +++++++----- docs/docs/es/queries.md | 12 ++++++------ docs/docs/es/recipes/data_migration.md | 4 ++-- docs/docs/es/recipes/full_text_search.md | 6 +++--- docs/docs/es/schema.md | 12 ++++++------ docs/docs/es/transactions.md | 14 +++++++------- docs/docs/fr/crud.md | 17 +++++++++-------- docs/docs/fr/indexes.md | 14 +++++++------- docs/docs/fr/links.md | 12 +++++++----- docs/docs/fr/queries.md | 12 ++++++------ docs/docs/fr/recipes/data_migration.md | 4 ++-- docs/docs/fr/recipes/full_text_search.md | 6 +++--- docs/docs/fr/schema.md | 12 ++++++------ docs/docs/fr/transactions.md | 14 +++++++------- docs/docs/indexes.md | 14 +++++++------- docs/docs/it/crud.md | 17 +++++++++-------- docs/docs/it/indexes.md | 14 +++++++------- docs/docs/it/links.md | 12 +++++++----- docs/docs/it/queries.md | 12 ++++++------ docs/docs/it/recipes/data_migration.md | 4 ++-- docs/docs/it/recipes/full_text_search.md | 6 +++--- docs/docs/it/schema.md | 12 ++++++------ docs/docs/it/transactions.md | 14 +++++++------- docs/docs/ja/crud.md | 17 +++++++++-------- docs/docs/ja/indexes.md | 14 +++++++------- docs/docs/ja/links.md | 12 +++++++----- docs/docs/ja/queries.md | 12 ++++++------ docs/docs/ja/recipes/data_migration.md | 4 ++-- docs/docs/ja/recipes/full_text_search.md | 6 +++--- docs/docs/ja/schema.md | 12 ++++++------ docs/docs/ja/transactions.md | 10 +++++----- docs/docs/ko/crud.md | 17 +++++++++-------- docs/docs/ko/indexes.md | 14 +++++++------- docs/docs/ko/links.md | 12 +++++++----- docs/docs/ko/queries.md | 12 ++++++------ docs/docs/ko/recipes/data_migration.md | 4 ++-- docs/docs/ko/recipes/full_text_search.md | 6 +++--- docs/docs/ko/schema.md | 12 ++++++------ docs/docs/ko/transactions.md | 10 +++++----- docs/docs/links.md | 12 +++++++----- docs/docs/pt/crud.md | 17 +++++++++-------- docs/docs/pt/indexes.md | 14 +++++++------- docs/docs/pt/links.md | 12 +++++++----- docs/docs/pt/queries.md | 12 ++++++------ docs/docs/pt/schema.md | 12 ++++++------ docs/docs/pt/transactions.md | 14 +++++++------- docs/docs/queries.md | 12 ++++++------ docs/docs/recipes/data_migration.md | 4 ++-- docs/docs/recipes/full_text_search.md | 6 +++--- docs/docs/schema.md | 12 ++++++------ docs/docs/transactions.md | 14 +++++++------- docs/docs/ur/crud.md | 17 +++++++++-------- docs/docs/ur/indexes.md | 14 +++++++------- docs/docs/ur/links.md | 12 +++++++----- docs/docs/ur/queries.md | 12 ++++++------ docs/docs/ur/recipes/data_migration.md | 4 ++-- docs/docs/ur/recipes/full_text_search.md | 6 +++--- docs/docs/ur/schema.md | 12 ++++++------ docs/docs/ur/transactions.md | 10 +++++----- docs/docs/zh/crud.md | 17 +++++++++-------- docs/docs/zh/indexes.md | 14 +++++++------- docs/docs/zh/links.md | 12 +++++++----- docs/docs/zh/queries.md | 12 ++++++------ docs/docs/zh/recipes/data_migration.md | 4 ++-- docs/docs/zh/recipes/full_text_search.md | 6 +++--- docs/docs/zh/schema.md | 12 ++++++------ docs/docs/zh/transactions.md | 10 +++++----- 78 files changed, 457 insertions(+), 427 deletions(-) diff --git a/docs/docs/crud.md b/docs/docs/crud.md index 9f7254333..d70c1a398 100644 --- a/docs/docs/crud.md +++ b/docs/docs/crud.md @@ -48,7 +48,7 @@ For the examples below, we assume that we have a collection `Recipe` defined as ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -115,7 +115,7 @@ final favorites = await isar.recipes.filter() It's finally time to modify our collection! To create, update, or delete objects, use the respective operations wrapped in a write transaction: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await isar.recipes.get(123) recipe.isFavorite = false; @@ -135,11 +135,12 @@ If the id field is `null` or `Isar.autoIncrement`, Isar will use an auto-increme ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.put(pancakes); }) ``` @@ -149,7 +150,7 @@ Isar will automatically assign the id to the object if the `id` field is non-fin Inserting multiple objects at once is just as easy: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.putAll([pancakes, pizza]); }) ``` @@ -161,7 +162,7 @@ Both creating and updating works with `collection.put(object)`. If the id is `nu So if we want to unfavorite our pancakes, we can do the following: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await isar.recipes.put(pancakes); }); @@ -172,7 +173,7 @@ await isar.writeTxn(() async { Want to get rid of an object in Isar? Use `collection.delete(id)`. The delete method returns whether an object with the specified id was found and deleted. If you want to delete the object with id `123`, for example, you can do: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await isar.recipes.delete(123); print('Recipe deleted: $success'); }); @@ -181,7 +182,7 @@ await isar.writeTxn(() async { Similarly to get and put, there is also a bulk delete operation that returns the number of deleted objects: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -190,7 +191,7 @@ await isar.writeTxn(() async { If you don't know the ids of the objects you want to delete, you can use a query: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/de/crud.md b/docs/docs/de/crud.md index 338e90d61..bf25a7910 100644 --- a/docs/docs/de/crud.md +++ b/docs/docs/de/crud.md @@ -45,7 +45,7 @@ Den folgenden Beispielen liegt die Collection `Recipe` zugrunde, die wie folgt d ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -112,7 +112,7 @@ final favourites = await recipes.filter() Jetzt ist es endlich an der Zeit, unsere Collection zu verändern! Um Objekte zu erstellen, zu aktualisieren oder zu löschen, rufe die entsprechenden Operationen innerhalb einer Schreibtransaktion auf: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await recipes.get(123) recipe.isFavorite = false; @@ -132,11 +132,12 @@ Wenn das ID-Feld `null` oder `Isar.autoIncrement` ist, verwendet Isar eine autom ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.put(pancakes); }) ``` @@ -146,7 +147,7 @@ Ist das ID-Feld nicht-final, weist Isar die generierte ID automatisch dem Objekt Das Erstellen von mehreren Objekten auf einmal ist genauso einfach: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.putAll([pancakes, pizza]); }) ``` @@ -158,7 +159,7 @@ Sowohl das Erstellen als auch das Aktualisieren funktioniert mit `collection.put Wenn wir also Pfannkuchen nicht mehr mögen, können wir Folgendes tun: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await recipes.put(recipe); }); @@ -169,7 +170,7 @@ await isar.writeTxn(() async { Willst du ein Objekt in Isar loswerden? Verwende `collection.delete(id)`. Die delete-Methode gibt zurück, ob ein Objekt mit der angegebenen ID gefunden und gelöscht wurde. Lass uns z.B. das Objekt mit der ID `123` löschen: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await recipes.delete(123); print('Recipe deleted: $success'); }); @@ -178,7 +179,7 @@ await isar.writeTxn(() async { Ähnlich wie bei `get()` und `put()` gibt es auch einen Massenlöschvorgang, der die Anzahl der gelöschten Objekte zurückgibt: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -187,7 +188,7 @@ await isar.writeTxn(() async { Wenn du die IDs der zu löschenden Objekte nicht kennst ist es auch möglich eine Abfrage zu verwenden: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/de/indexes.md b/docs/docs/de/indexes.md index 8f1944dfa..e038255a9 100644 --- a/docs/docs/de/indexes.md +++ b/docs/docs/de/indexes.md @@ -15,7 +15,7 @@ Zum Beispiel ist diese `Product`-Collection komplett unsortiert. ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ Um die Leistung dieser Abfrage zu verbessern, indizieren wir die Eigenschaft `pr ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ Ein eindeutiger Index stellt sicher, dass der Index keine doppelten Werte enthä ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ Manchmal ist es nicht von Vorteil einen Fehler zu verursachen, wenn eine Eindeut ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ Alle Indizes auf `String`- und `List`-Eigenschaften beachten standardmä ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ Es ist vermutlich am besten mit einem Beispiel zu starten. Wir erstellen eine Pe ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ Zu sinnvollen Anwendungen für Mehrfach-Indizes zählen das Indizieren einer Lis ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/de/links.md b/docs/docs/de/links.md index 000c5fdb8..b1905525f 100644 --- a/docs/docs/de/links.md +++ b/docs/docs/de/links.md @@ -2,6 +2,8 @@ title: Links --- +> ⚠️ Links are currently not supported in Isar v4 + # Links Links ermöglichen es dir Verhältnisse zwischen Objekten, wie z.B. dem Autor (Benutzer) eines Kommentars, auszudrücken. Du kannst `1:1`, `1:n`, `n:m` Verhältnisse mit Isar-Links modellieren. Links zu nutzen ist unpraktischer als eingebettete Objekte zu benutzen, und du solltest eingebettete Objekte, wann immer möglich, verwenden. @@ -23,14 +25,14 @@ Für nicht-Web-Ziele werden Links automatisch geladen, wenn du sie zum ersten Ma ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teachers.save(); @@ -91,7 +93,7 @@ Intern werden `IsarLink` und `IsarLinks` auf die gleiche Weise dargestellt. Wir ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -113,7 +115,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/de/queries.md b/docs/docs/de/queries.md index 79cfcf907..f9786c5bf 100644 --- a/docs/docs/de/queries.md +++ b/docs/docs/de/queries.md @@ -26,7 +26,7 @@ Wir benutzen das folgende Modell für die Beispiele weiter unten: ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -199,7 +199,7 @@ Abfragen können sogar auf Listen gestellt werden: ```dart class Tweet { - Id? id; + late int id; String? text; @@ -236,7 +236,7 @@ Eingebettete Objekte sind eines von Isars nützlichsten Features. Sie können se ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -281,14 +281,14 @@ Beachte, dass Link-Abfragen teuer sein können, weil Isar die verlinkten Objekte ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -340,7 +340,7 @@ Lass uns Indizes zu der Schuh-Collection hinzufügen: ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/de/recipes/data_migration.md b/docs/docs/de/recipes/data_migration.md index 60bc0e497..9bbf4db5d 100644 --- a/docs/docs/de/recipes/data_migration.md +++ b/docs/docs/de/recipes/data_migration.md @@ -18,7 +18,7 @@ Version 1: ```dart @collection class User { - Id? id; + late int id; late String name; @@ -30,7 +30,7 @@ Version 2: ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/de/recipes/full_text_search.md b/docs/docs/de/recipes/full_text_search.md index 4eef6fe9d..9a2c06c05 100644 --- a/docs/docs/de/recipes/full_text_search.md +++ b/docs/docs/de/recipes/full_text_search.md @@ -24,7 +24,7 @@ Bauen wir den grundlegendsten Volltext-Index: ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ Das ist kinderleicht! Wir können unseren Index so ändern, dass er auch Präfix ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ Klar! Wir werden einen Trick verwenden, um `.endsWith()` verwenden zu können: ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/de/schema.md b/docs/docs/de/schema.md index b470405a6..fb0847c49 100644 --- a/docs/docs/de/schema.md +++ b/docs/docs/de/schema.md @@ -17,7 +17,7 @@ Der folgende Code ist ein Beispiel einer simplen Collection, welche eine `User`- ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar stell sicher, dass alle öffentlichen Felder einer Collecion-Klasse erhalte ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -155,7 +155,7 @@ Hier ist eine Beispiel-Collection, welche alle der eben genannten Typen enthält ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -216,7 +216,7 @@ Schauen wir uns ein Beispiel für jede Strategie an. ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // entspricht EnumType.ordinal late TestEnum byteIndex; // ist nicht Null-bar @@ -254,7 +254,7 @@ Es ist oft hilfreich verschachtelte Objekte in deinem Collection-Modell zu haben ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/de/transactions.md b/docs/docs/de/transactions.md index 0d93df973..e30f614ac 100644 --- a/docs/docs/de/transactions.md +++ b/docs/docs/de/transactions.md @@ -14,10 +14,10 @@ Transaktionen (besonders Schreib-Transaktionen) sind sehr teuer. Du solltest imm Transaktionen können entweder synchron oder asynchron sein. In synchronen Transaktionen kannst du nur synchrone Operationen verwenden. In asynchronen Transaktionen sind nur asynchrone Operationen möglich. -| | Lesen | Lesen & Schreiben | -| --------- | ------------ | ----------------- | -| Synchron | `.txnSync()` | `.writeTxnSync()` | -| Asynchron | `.txn()` | `.writeTxn()` | +| | Lesen | Lesen & Schreiben | +| --------- | -------------- | ----------------- | +| Synchron | `.read()` | `.write()` | +| Asynchron | `.readAsync()` | `.writeAsync()` | ### Lese-Transaktionen @@ -40,13 +40,13 @@ Wenn eine Datenbankoperation fehlschlägt, wird die Transaktion abgeborchen und ```dart @collection class Contact { - Id? id; + late int id; String? name; } // GUT -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -54,7 +54,7 @@ await isar.writeTxn(() async { // SCHLECHT: Bewege die Schleife in die Transaktion for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/es/crud.md b/docs/docs/es/crud.md index 2209134b3..944a8d958 100644 --- a/docs/docs/es/crud.md +++ b/docs/docs/es/crud.md @@ -47,7 +47,7 @@ Para los ejemplos siguientes, asumimos que tenemos una colección `Recipe` defin ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -114,7 +114,7 @@ final favouires = await recipes.filter() Finalmente es momento de modificar los datos en nuestra colección! Para crear, actualizar o eliminar objectos, usa las respectivas operaciones juntas en una transacción de escritura: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await recipes.get(123) recipe.isFavorite = false; @@ -134,11 +134,12 @@ Si el campo id es `null` o `Isar.autoIncrement`, Isar usará un id auto incremen ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.put(pancakes); }) ``` @@ -148,7 +149,7 @@ Isar asignará automáticamente el id al objeto si el campo id es no-final. Insertar múltiples objetos de una sola vez es muy fácil: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.putAll([pancakes, pizza]); }) ``` @@ -160,7 +161,7 @@ Crear y actualizar objetos funcionan ambos con `collection.put(object)`. Si el i Entonces si queremos quitar los pancakes de los favoritos, podemos hacer los siguiente: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await recipes.put(recipe); }); @@ -171,7 +172,7 @@ await isar.writeTxn(() async { Quieres eliminar un objeto en Isar? Usa `collection.delete(id)`. El método delete retorna verdadero si el objeto con el id especificado fue encontrado y eliminado. Por ejemplo, si quieres eliminar el objeto con el id `123`, puedes hacer: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await recipes.delete(123); print('Recipe deleted: $success'); }); @@ -180,7 +181,7 @@ await isar.writeTxn(() async { De manera similar a get y put, también existe una operación para eliminar múltiples objetos de una vez que retorna la cantidad de objetos eliminados: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -189,7 +190,7 @@ await isar.writeTxn(() async { Si no conoces los ids de los objetos que quieres eliminar, puedes utilizar una consulta: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/es/indexes.md b/docs/docs/es/indexes.md index 1ccd0800b..bbbb3a0dc 100644 --- a/docs/docs/es/indexes.md +++ b/docs/docs/es/indexes.md @@ -15,7 +15,7 @@ Por ejemplo, esta colección `Product` está completamente desordenada. ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ Para mejorar el rendimiento de esta consulta, indexamos la propiedad `price`. Un ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ Un índice único asegura que el índice no contiene valores duplicados. Puede c ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ A veces no es deseable arrojar un error si una condición de único es violada. ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ Todos los índices en las propiedades `String` y `List` por defecto dist ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ Probablemente sea mejor comenzar con un ejemplo. Creamos una colleción person y ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ Aplicaciones prácticas del uso de índices multi-entrada incluyen indexar una l ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/es/links.md b/docs/docs/es/links.md index 01227fc97..6b99d630e 100644 --- a/docs/docs/es/links.md +++ b/docs/docs/es/links.md @@ -2,6 +2,8 @@ title: Enlaces --- +> ⚠️ Links are currently not supported in Isar v4 + # Enlaces Los enlaces permiten establecer relaciones entre objetos, como ser el autor de un comentario (User). Con los enlaces de Isar, se pueden modelar relaciones `1:1`, `1:n`, y `n:n`. Usar enlaces es menos ergonómico que usar objetos embebidos y se deberían usar los últimos siempre que sea posible. @@ -23,14 +25,14 @@ En las plataformas no web, los enlaces se cargan automáticamente cuando los usa ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teacher.save(); @@ -91,7 +93,7 @@ Internamente ambos `IsarLink` y `IsarLinks` se representan de la misma forma. Po ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -113,7 +115,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/es/queries.md b/docs/docs/es/queries.md index cea4cdc41..3e662b673 100644 --- a/docs/docs/es/queries.md +++ b/docs/docs/es/queries.md @@ -25,7 +25,7 @@ Usaremos el modelo siguiente para los ejemplos: ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -198,7 +198,7 @@ Incluso se puede construir consultas sobre listas: ```dart class Tweet { - Id? id; + late int id; String? text; @@ -235,7 +235,7 @@ Los objetos embebidos son una de las funcionalidades más útiles de Isar. Se pu ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -280,14 +280,14 @@ Ten en cuenta que las consultas sobre enlaces pueden ser costosas ya que Isar ne ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -339,7 +339,7 @@ Agreguemos ídices a nuestra colección shoe: ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/es/recipes/data_migration.md b/docs/docs/es/recipes/data_migration.md index 88bf3678c..823ab7c25 100644 --- a/docs/docs/es/recipes/data_migration.md +++ b/docs/docs/es/recipes/data_migration.md @@ -19,7 +19,7 @@ Version 1: ```dart @collection class User { - Id? id; + late int id; late String name; @@ -32,7 +32,7 @@ Version 2: ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/es/recipes/full_text_search.md b/docs/docs/es/recipes/full_text_search.md index 6d1632f2d..90d0d59f2 100644 --- a/docs/docs/es/recipes/full_text_search.md +++ b/docs/docs/es/recipes/full_text_search.md @@ -24,7 +24,7 @@ Creamos el índice full-text más básico: ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ Pan comido! Podemos cambiar nuestro índice para soportar también coincidencia ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ Por supuesto! Usaremos un truco para conseguir la coincidencia `.endsWith()`: ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/es/schema.md b/docs/docs/es/schema.md index af5e3d191..5336abc69 100644 --- a/docs/docs/es/schema.md +++ b/docs/docs/es/schema.md @@ -17,7 +17,7 @@ El código siguiente es un ejemplo de una colección simple que define una table ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar almacena todos los campos públicos de una clase que defina una colección. ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -155,7 +155,7 @@ El siguiente es un ejemplo de una colección que contiene todos los tipos de dat ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -216,7 +216,7 @@ Veamos un ejemplo para cada estrategia. ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // same as EnumType.ordinal late TestEnum byteIndex; // cannot be nullable @@ -254,7 +254,7 @@ Con frecuencia es útil tener objetos anidados en tus colecciones. No hay límit ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/es/transactions.md b/docs/docs/es/transactions.md index 78bdd33ef..3dd52f82b 100644 --- a/docs/docs/es/transactions.md +++ b/docs/docs/es/transactions.md @@ -14,10 +14,10 @@ Las transacciones (especialmente las de escritura) tienen un costo, y siempre de Las transacciones puede ser tanto síncronas como asíncronas. En las transacciones síncronas, sólo puedes utilizar operaciones síncronas. En las transacciones asíncronas, sólo operaciones asíncronas. -| | Lectura | Lectura y Escritura | -| ---------- | ------------ | ------------------- | -| Síncronas | `.txnSync()` | `.writeTxnSync()` | -| Asíncronas | `.txn()` | `.writeTxn()` | +| | Lectura | Lectura y Escritura | +| ---------- | -------------- | ------------------- | +| Síncronas | `.read()` | `.write()` | +| Asíncronas | `.readAsync()` | `.writeAsync()` | ### Transacciones de lectura @@ -40,13 +40,13 @@ Cuando una operación de la base de datos falla, la transacción se aborta y ya ```dart @collection class Contact { - Id? id; + late int id; String? name; } // GOOD -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -54,7 +54,7 @@ await isar.writeTxn(() async { // BAD: move loop inside transaction for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/fr/crud.md b/docs/docs/fr/crud.md index a818e26d1..6dff0dde6 100644 --- a/docs/docs/fr/crud.md +++ b/docs/docs/fr/crud.md @@ -47,7 +47,7 @@ Pour les exemples ci-dessous, nous supposons que nous avons une collection `Reci ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -115,7 +115,7 @@ final favouires = await recipes.filter() Il est enfin temps de modifier notre collection! Pour créer, mettre à jour ou supprimer des objets, utilisez les opérations respectives dans une transaction d'écriture: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await recipes.get(123) recipe.isFavorite = false; @@ -135,11 +135,12 @@ Si le champ id est `null` ou `Isar.autoIncrement`, Isar utilisera un id auto-inc ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.put(pancakes); }) ``` @@ -149,7 +150,7 @@ Isar attribuera automatiquement l'id à l'objet si le champ `id` est non final. Il est tout aussi facile d'insérer plusieurs objets à la fois: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.putAll([pancakes, pizza]); }) ``` @@ -161,7 +162,7 @@ La création et la mise à jour fonctionnent toutes deux avec `collection.put(ob Donc si nous voulons défavoriser nos crêpes, nous pouvons faire ce qui suit: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await recipes.put(pancakes); }); @@ -172,7 +173,7 @@ await isar.writeTxn(() async { Vous voulez vous débarrasser d'un objet dans Isar ? Utilisez `collection.delete(id)`. La méthode `delete` retourne si un objet avec l'identifiant spécifié a été trouvé et supprimé. Si nous désirons supprimer l'objet avec l'identifiant `123`, par exemple, nous pouvons faire: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await recipes.delete(123); print('Recipe deleted: $success'); }); @@ -181,7 +182,7 @@ await isar.writeTxn(() async { Comme pour les opérations `get` et `put`, il existe également une opération de suppression en vrac qui renvoie le nombre d'objets supprimés: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -190,7 +191,7 @@ await isar.writeTxn(() async { Si nous ne connaissons pas les identifiants des objets que nous voulons supprimer, nous pouvons utiliser une requête: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/fr/indexes.md b/docs/docs/fr/indexes.md index b146bccee..b1954ad3a 100644 --- a/docs/docs/fr/indexes.md +++ b/docs/docs/fr/indexes.md @@ -15,7 +15,7 @@ Par exemple, cette collection `Product` est entièrement non ordonnée. ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ Pour améliorer les performances de cette requête, nous indexons la propriété ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ Un index unique garantit que l'index ne contient pas de valeurs en double. Il pe ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ Il n'est parfois pas préférable d'envoyer une erreur si une contrainte unique ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ Tous les index sur les propriétés `String` et `List` sont sensibles à ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ Il est probablement préférable de commencer par un exemple. Nous créons une c ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ Les applications pratiques des index à entrées multiples comprennent l'indexat ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/fr/links.md b/docs/docs/fr/links.md index a81efeee6..b51f87e91 100644 --- a/docs/docs/fr/links.md +++ b/docs/docs/fr/links.md @@ -2,6 +2,8 @@ title: Liens --- +> ⚠️ Links are currently not supported in Isar v4 + # Liens Les liens nous permettent d'exprimer des relations entre objets, comme l'auteur d'un commentaire (`User`). Nous pouvons modéliser des relations `1:1`, `1:n`, et `n:n` avec les liens Isar. L'utilisation de liens est moins ergonomique que l'utilisation d'objets embarqués. Il est donc préférable d'utiliser des objets embarqués lorsque possible. @@ -23,14 +25,14 @@ Pour les plateformes autres que web, les liens sont chargés automatiquement lor ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teacher.save(); @@ -91,7 +93,7 @@ La représentation interne de `IsarLink` et `IsarLinks` est la même. Nous pouvo ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -113,7 +115,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/fr/queries.md b/docs/docs/fr/queries.md index ca071d9e8..28c915381 100644 --- a/docs/docs/fr/queries.md +++ b/docs/docs/fr/queries.md @@ -25,7 +25,7 @@ Nous utiliserons le modèle suivant pour les exemples ci-dessous: ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -198,7 +198,7 @@ Même les listes peuvent être utilisées dans les requêtes: ```dart class Tweet { - Id? id; + late int id; String? text; @@ -235,7 +235,7 @@ Les objets embarqués sont l'une des fonctionnalités les plus utiles d'Isar. Il ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -280,14 +280,14 @@ Gardez en tête que les requêtes de liens peuvent être coûteuses, car Isar do ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -339,7 +339,7 @@ Ajoutons des index à la collection `Shoe`: ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/fr/recipes/data_migration.md b/docs/docs/fr/recipes/data_migration.md index 7ef094e62..028814982 100644 --- a/docs/docs/fr/recipes/data_migration.md +++ b/docs/docs/fr/recipes/data_migration.md @@ -18,7 +18,7 @@ Version 1: ```dart @collection class User { - Id? id; + late int id; late String name; @@ -30,7 +30,7 @@ Version 2: ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/fr/recipes/full_text_search.md b/docs/docs/fr/recipes/full_text_search.md index cb316634a..9508ad161 100644 --- a/docs/docs/fr/recipes/full_text_search.md +++ b/docs/docs/fr/recipes/full_text_search.md @@ -24,7 +24,7 @@ Créons l'index plein texte le plus basique: ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ C'est simple et facile! Nous pouvons également modifier notre index pour suppor ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ Bien sûr! Nous allons utiliser une astuce pour réaliser la comparaison `.endsW ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/fr/schema.md b/docs/docs/fr/schema.md index c1156e13c..6985cda40 100644 --- a/docs/docs/fr/schema.md +++ b/docs/docs/fr/schema.md @@ -17,7 +17,7 @@ Le code suivant est un exemple d'une collection simple qui définit une table `U ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar persiste tous les champs publics d'une classe de collection. En annotant un ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -155,7 +155,7 @@ Voici un exemple de collection contenant les types décrit ci-dessus: ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -216,7 +216,7 @@ Voici un exemple pour chaque stratégie: ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // Même chose que EnumType.ordinal late TestEnum byteIndex; // Ne peut pas être nulle @@ -254,7 +254,7 @@ Il est souvent utile d'avoir des objets imbriqués dans votre modèle de collect ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/fr/transactions.md b/docs/docs/fr/transactions.md index da8680481..3b46f7ab0 100644 --- a/docs/docs/fr/transactions.md +++ b/docs/docs/fr/transactions.md @@ -14,10 +14,10 @@ Les transactions (en particulier les transactions d'écriture) ont un coût, et Les transactions peuvent être soit synchrones ou asynchrones. Dans les transactions synchrones, nous ne pouvons utiliser que les opérations synchrones. Dans les transactions asynchrones, uniquement les opérations asynchrones. -| | Lecture | Lecture et écriture | -|-------------|--------------|---------------------| -| Synchrones | `.txnSync()` | `.writeTxnSync()` | -| Asynchrones | `.txn()` | `.writeTxn()` | +| | Lecture | Lecture et écriture | +|-------------|--------------- |-------------------- | +| Synchrones | `.read()` | `.write()` | +| Asynchrones | `.readAsync()` | `.writeAsync()` | ### Transactions de lecture @@ -41,13 +41,13 @@ Lorsqu'une opération de base de données échoue, la transaction est interrompu ```dart @collection class Contact { - Id? id; + late int id; String? name; } // BON -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -55,7 +55,7 @@ await isar.writeTxn(() async { // MAUVAIS : déplacer la boucle à l'intérieur de la transaction for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/indexes.md b/docs/docs/indexes.md index 4e8e652f2..037124647 100644 --- a/docs/docs/indexes.md +++ b/docs/docs/indexes.md @@ -15,7 +15,7 @@ For example, this `Product` collection is entirely unordered. ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ To improve the performance of this query, we index the `price` property. An inde ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ A unique index ensures the index does not contain any duplicate values. It may c ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ It is sometimes not preferable to throw an error if a unique constraint is viola ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ All indexes on `String` and `List` properties are case-sensitive by defa ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ It's probably best to start with an example. We create a person collection and d ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ Practical applications for multi-entry indexes include indexing a list of tags o ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/it/crud.md b/docs/docs/it/crud.md index a6d6ade09..61bf0d696 100644 --- a/docs/docs/it/crud.md +++ b/docs/docs/it/crud.md @@ -47,7 +47,7 @@ Per gli esempi seguenti, assumiamo di avere una raccolta "Ricetta" definita come ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -114,7 +114,7 @@ final favouires = await recipes.filter() È finalmente arrivato il momento di modificare la nostra collezione! Per creare, aggiornare o eliminare oggetti, utilizzare le rispettive operazioni racchiuse in una transazione di scrittura: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await recipes.get(123) recipe.isFavorite = false; @@ -134,11 +134,12 @@ Se il campo id è `null` o `Isar.autoIncrement`, Isar utilizzerà un id di incre ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.put(pancakes); }) ``` @@ -148,7 +149,7 @@ Isar assegnerà automaticamente l'id all'oggetto se il campo `id` non è definit Inserire più oggetti contemporaneamente è altrettanto facile: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.putAll([pancakes, pizza]); }) ``` @@ -160,7 +161,7 @@ Sia la creazione che l'aggiornamento funzionano con `collection.put(object)`. Se Quindi, se vogliamo eliminare i nostri pancake dai preferiti, possiamo fare quanto segue: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await recipes.put(recipe); }); @@ -171,7 +172,7 @@ await isar.writeTxn(() async { Vuoi sbarazzarti di un oggetto in Isar? Usa `collection.delete(id)`. Il metodo delete restituisce se un oggetto con l'ID specificato è stato trovato ed eliminato. Se vuoi eliminare l'oggetto con id `123`, ad esempio, puoi fare: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await recipes.delete(123); print('Recipe deleted: $success'); }); @@ -180,7 +181,7 @@ await isar.writeTxn(() async { Allo stesso modo per get e put, esiste anche un'operazione di eliminazione in blocco che restituisce il numero di oggetti eliminati: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -189,7 +190,7 @@ await isar.writeTxn(() async { Se non conosci gli ID degli oggetti che desideri eliminare, puoi utilizzare una query: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/it/indexes.md b/docs/docs/it/indexes.md index 11c1e599e..a79e64ff5 100644 --- a/docs/docs/it/indexes.md +++ b/docs/docs/it/indexes.md @@ -15,7 +15,7 @@ Ad esempio, questa raccolta `Product` non è ordinata. ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ Per migliorare le prestazioni di questa query, indicizziamo la proprietà `price ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ Un indice univoco garantisce che l'indice non contenga valori duplicati. Può es ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ A volte non è preferibile generare un errore se viene violato un vincolo univoc ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ Tutti gli indici sulle proprietà `String` e `List` fanno distinzione tr ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ Probabilmente è meglio iniziare con un esempio. Creiamo una collezione di perso ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ Le applicazioni pratiche per gli indici a voci multiple includono l'indicizzazio ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/it/links.md b/docs/docs/it/links.md index edbf5bf9b..8a101fa37 100644 --- a/docs/docs/it/links.md +++ b/docs/docs/it/links.md @@ -2,6 +2,8 @@ title: Collegamenti --- +> ⚠️ Links are currently not supported in Isar v4 + # Collegamenti I collegamenti consentono di esprimere relazioni tra oggetti, come l'autore di un commento (Utente). Puoi modellare le relazioni `1:1`, `1:n` e `n:n` con i collegamenti Isar. L'uso dei collegamenti è meno ergonomico rispetto all'utilizzo di oggetti incorporati e dovresti utilizzare oggetti incorporati quando possibile. @@ -23,14 +25,14 @@ Per i target non web, i link vengono caricati automaticamente quando li usi per ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teacher.save(); @@ -91,7 +93,7 @@ Internamente sia "IsarLink" che "IsarLinks" sono rappresentati allo stesso modo. ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -113,7 +115,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/it/queries.md b/docs/docs/it/queries.md index 80a8b88ba..9b4372b6f 100644 --- a/docs/docs/it/queries.md +++ b/docs/docs/it/queries.md @@ -25,7 +25,7 @@ Utilizzeremo il seguente modello per gli esempi seguenti: ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -199,7 +199,7 @@ Si possono interrogare anche le liste: ```dart class Tweet { - Id? id; + late int id; String? text; @@ -236,7 +236,7 @@ Gli oggetti incorporati sono una delle funzionalità più utili di Isar. Possono ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -281,14 +281,14 @@ Tieni presente che le query di collegamento possono essere costose perché Isar ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -340,7 +340,7 @@ Aggiungiamo gli indici alla collezione di scarpe: ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/it/recipes/data_migration.md b/docs/docs/it/recipes/data_migration.md index 4925c0c27..51390f2a0 100644 --- a/docs/docs/it/recipes/data_migration.md +++ b/docs/docs/it/recipes/data_migration.md @@ -18,7 +18,7 @@ Versione 1: ```dart @collection class User { - Id? id; + late int id; late String name; @@ -30,7 +30,7 @@ Versione 2: ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/it/recipes/full_text_search.md b/docs/docs/it/recipes/full_text_search.md index 355f03c84..3a9815511 100644 --- a/docs/docs/it/recipes/full_text_search.md +++ b/docs/docs/it/recipes/full_text_search.md @@ -24,7 +24,7 @@ Creiamo l'indice full-text più semplice: ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ Facilissimo! Possiamo modificare il nostro indice anche per supportare la corris ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ Sicuramente! Useremo un trucco per ottenere la corrispondenza `.endsWith()`: ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/it/schema.md b/docs/docs/it/schema.md index 041150d99..1336a7cc9 100644 --- a/docs/docs/it/schema.md +++ b/docs/docs/it/schema.md @@ -17,7 +17,7 @@ Il codice seguente è un esempio di una raccolta semplice che definisce una tabe ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar mantiene tutti i campi pubblici di una classe di raccolta. Annotando una pr ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -155,7 +155,7 @@ Ecco una raccolta di esempio contenente tutti i tipi di cui sopra: ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -216,7 +216,7 @@ Diamo un'occhiata a un esempio per ciascuna strategia. ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // same as EnumType.ordinal late TestEnum byteIndex; // cannot be nullable @@ -254,7 +254,7 @@ Spesso è utile avere oggetti nidificati nel modello di raccolta. Non c'è limit ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/it/transactions.md b/docs/docs/it/transactions.md index 2bdf6aed1..0a1bdb679 100644 --- a/docs/docs/it/transactions.md +++ b/docs/docs/it/transactions.md @@ -14,10 +14,10 @@ Le transazioni (in particolare le transazioni di scrittura) hanno un costo e dov Le transazioni possono essere sincrone o asincrone. Nelle transazioni sincrone è possibile utilizzare solo operazioni sincrone. Nelle transazioni asincrone, solo operazioni asincrone. -| | Read | Read & Write | -|--------------|--------------|--------------------| -| Synchronous | `.txnSync()` | `.writeTxnSync()` | -| Asynchronous | `.txn()` | `.writeTxn()` | +| | Read | Read & Write | +|--------------|----------------|--------------------| +| Synchronous | `.read()` | `.write()` | +| Asynchronous | `.readAsync()` | `.writeAsync()` | ### Transazioni di lettura @@ -41,13 +41,13 @@ Quando un'operazione di database ha esito negativo, la transazione viene interro ```dart @collection class Contact { - Id? id; + late int id; String? name; } // GOOD -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -55,7 +55,7 @@ await isar.writeTxn(() async { // BAD: move loop inside transaction for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/ja/crud.md b/docs/docs/ja/crud.md index 47aae5845..434ee3897 100644 --- a/docs/docs/ja/crud.md +++ b/docs/docs/ja/crud.md @@ -47,7 +47,7 @@ final isar = await Isar.open( ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -114,7 +114,7 @@ final favouires = await recipes.filter() いよいよコレクションを書き換えるときがやってきました! オブジェクトを作成、更新、削除するには、それぞれの操作をWriteトランザクション内でラップして使用します: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await recipes.get(123) recipe.isFavorite = false; @@ -136,11 +136,12 @@ Isar の `put()` メソッドは、そのオブジェクトが既にコレクシ ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.put(pancakes); }) ``` @@ -150,7 +151,7 @@ Isarは `id` フィールドがfinalでは無い場合、オブジェクトに 複数のオブジェクトを一度に挿入することも簡単です。 ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await recipes.putAll([pancakes, pizza]); }) ``` @@ -162,7 +163,7 @@ await isar.writeTxn(() async { つまり、pancakesをunfavoriteにしたい場合は、以下のようになります: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await recipes.put(recipe); }); @@ -173,7 +174,7 @@ await isar.writeTxn(() async { オブジェクトを削除したい場合は、`collection.delete(id)`を使用してください. delete メソッドは、指定された id を持つオブジェクトを見つけて、それを削除したかどうかを返します。例えば、id が `123` のオブジェクトを削除したい場合、以下のようになります。 ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await recipes.delete(123); print('Recipe deleted: $success'); }); @@ -182,7 +183,7 @@ await isar.writeTxn(() async { getやputと同様に、削除されたオブジェクトの数を返す一括削除命令も存在します: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -191,7 +192,7 @@ await isar.writeTxn(() async { 削除したいオブジェクトのidが分からない場合は、クエリを使用することができます: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/ja/indexes.md b/docs/docs/ja/indexes.md index 4c7e02070..11ff1c1cc 100644 --- a/docs/docs/ja/indexes.md +++ b/docs/docs/ja/indexes.md @@ -18,7 +18,7 @@ title: インデックス ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -53,7 +53,7 @@ final expensiveProducts = await isar.products.filter() ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -113,7 +113,7 @@ final cheapestFast = await isar.products.where() ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -150,7 +150,7 @@ print(await isar.user.where().findAll()); ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -209,7 +209,7 @@ await isar.user.where().findAll(); // -> [{id: 1, username: 'user1' age: 30}] ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -258,7 +258,7 @@ Valueインデックスは既定の型であり、StringやListを保持しな ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -323,7 +323,7 @@ IndexType.valueを使ってListのインデックスを作成すると、Isarは ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/ja/links.md b/docs/docs/ja/links.md index bf32cfc7c..4feaf3f0a 100644 --- a/docs/docs/ja/links.md +++ b/docs/docs/ja/links.md @@ -2,6 +2,8 @@ title: リンク --- +> ⚠️ Links are currently not supported in Isar v4 + # リンク リンクは、例えばコメントの作成者(User)のようなオブジェクト間の関係を表現することができ、 `1:1`、`1:n`、`n:n`の関係を IsarLinkで表現することができます。リンクの使用は、埋め込みオブジェクトの使用よりも人間工学的に劣るので、可能な限り埋め込みオブジェクトを使用するようにしましょう。 @@ -23,14 +25,14 @@ Web 以外の対象ついては、リンクは初めて使用する際に自動 ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teacher.save(); @@ -91,7 +93,7 @@ isar.writeTxnSync(() { ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -114,7 +116,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/ja/queries.md b/docs/docs/ja/queries.md index cac212e3a..67b9a92fe 100644 --- a/docs/docs/ja/queries.md +++ b/docs/docs/ja/queries.md @@ -26,7 +26,7 @@ title: クエリ ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -199,7 +199,7 @@ Listにおいてもクエリが可能です: ```dart class Tweet { - Id? id; + late int id; String? text; @@ -236,7 +236,7 @@ final flutterTweets = await isar.tweets.filter() ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -281,14 +281,14 @@ final germanCars = await isar.cars.filter() ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -340,7 +340,7 @@ where節を組み合わせるには、**論理和**しか使えません。言 ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/ja/recipes/data_migration.md b/docs/docs/ja/recipes/data_migration.md index 33bc33f23..563af0ff1 100644 --- a/docs/docs/ja/recipes/data_migration.md +++ b/docs/docs/ja/recipes/data_migration.md @@ -18,7 +18,7 @@ Version 1: ```dart @collection class User { - Id? id; + late int id; late String name; @@ -30,7 +30,7 @@ Version 2: ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/ja/recipes/full_text_search.md b/docs/docs/ja/recipes/full_text_search.md index 045ec38e9..e9802cd4a 100644 --- a/docs/docs/ja/recipes/full_text_search.md +++ b/docs/docs/ja/recipes/full_text_search.md @@ -24,7 +24,7 @@ IsarDB ではフィルタを使って簡単にテキストを検索すること ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ Isar.splitWords('The quick (“brown”) fox can’t jump 32.3 feet, right?'); ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ final posts = await isar.posts ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/ja/schema.md b/docs/docs/ja/schema.md index 7f0267900..381077d95 100644 --- a/docs/docs/ja/schema.md +++ b/docs/docs/ja/schema.md @@ -17,7 +17,7 @@ Isar コレクションを定義するには、Class を `@collection` または ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar は、コレクションクラスのすべての public フィールドを ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -155,7 +155,7 @@ Isar は以下のデータ型に対応しています: ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -218,7 +218,7 @@ Isar では他の型と同様に、列挙型を保存し使用することがで ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // EnumType.ordinalと同様 late TestEnum byteIndex; // null 許容には出来ない @@ -256,7 +256,7 @@ enum TestEnum { ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/ja/transactions.md b/docs/docs/ja/transactions.md index 58ae766cc..6a370eaa8 100644 --- a/docs/docs/ja/transactions.md +++ b/docs/docs/ja/transactions.md @@ -16,8 +16,8 @@ Isarにおいて、トランザクションは複数のデータベース操作 | | Read | Read & Write | |--------------|--------------|--------------------| -| 同期 | `.txnSync()` | `.writeTxnSync()` | -| 非同期 | `.txn()` | `.writeTxn()` | +| 同期 | `.read()` | `.write()` | +| 非同期 | `.readAsync()` | `.writeAsync()` | ### 読み取りトランザクション @@ -41,13 +41,13 @@ Isarにおいて、トランザクションは複数のデータベース操作 ```dart @collection class Contact { - Id? id; + late int id; String? name; } // GOOD -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -55,7 +55,7 @@ await isar.writeTxn(() async { // BAD: トランザクションの中にforループを移動させましょう。 for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/ko/crud.md b/docs/docs/ko/crud.md index 2af7d34ca..90207baf4 100644 --- a/docs/docs/ko/crud.md +++ b/docs/docs/ko/crud.md @@ -48,7 +48,7 @@ Isar 에서 지정된 타입의 새로운 객체를 찾고 쿼리하고 생성 ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -115,7 +115,7 @@ final favouires = await isar.recipes.filter() 드디어 컬렉션을 수정할 때가 됐습니다! 객체를 생성, 갱신, 삭제하려면 쓰기 트랜잭션 안에서 각각의 작업들을 수행하세요. ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await isar.recipes.get(123) recipe.isFavorite = false; @@ -135,11 +135,12 @@ id 필드가 `null` 이나 `Isar.autoIncrement` 라면, Isar 는 자동 증분 ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.put(pancakes); }) ``` @@ -149,7 +150,7 @@ await isar.writeTxn(() async { 여러 객체를 한 번에 삽입하는 것도 쉽습니다: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.putAll([pancakes, pizza]); }) ``` @@ -161,7 +162,7 @@ await isar.writeTxn(() async { 만약 팬케익에 즐겨찾기를 해제하는 경우, 이렇게 할 수 있습니다. ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await isar.recipes.put(pancakes); }); @@ -172,7 +173,7 @@ await isar.writeTxn(() async { Isar 에 있는 것을 없애고 싶나요? `collection.delete(id)` 를 사용하세요. delete 메소드는 주어진 id 를 가진 객체를 찾아서 삭제합니다. id `123` 을 가지는 객체를 삭제하는 예시 입니다: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await isar.recipes.delete(123); print('Recipe deleted: $success'); }); @@ -181,7 +182,7 @@ await isar.writeTxn(() async { get 과 put 과 마찬가지로 delete 에도 여러개를 한꺼번에 삭제하는 방법이 있습니다. 삭제된 객체의 수를 반환합니다. ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -190,7 +191,7 @@ await isar.writeTxn(() async { 만약 삭제할 객체의 id 를 모른다면 query 를 사용할 수 있습니다. ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/ko/indexes.md b/docs/docs/ko/indexes.md index 011be41b2..a98ab21ab 100644 --- a/docs/docs/ko/indexes.md +++ b/docs/docs/ko/indexes.md @@ -15,7 +15,7 @@ title: 인덱스 ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ final expensiveProducts = await isar.products.filter() ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ final cheapestFast = await isar.products.where() ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ print(await isar.user.where().findAll()); ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ All indexes on `String` and `List` properties are case-sensitive by defa ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ It's probably best to start with an example. We create a person collection and d ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ Practical applications for multi-entry indexes include indexing a list of tags o ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/ko/links.md b/docs/docs/ko/links.md index fa386b954..1c5a752d1 100644 --- a/docs/docs/ko/links.md +++ b/docs/docs/ko/links.md @@ -2,6 +2,8 @@ title: 링크 --- +> ⚠️ Links are currently not supported in Isar v4 + # 링크 링크를 사용해서 댓글 작성자(사용자) 같은 객체 간의 관계를 나타낼 수 있습니다. Isar 링크를 사용해서 `1:1`, `1:n`, 과 `n:n` 관계를 모델링할 수 있습니다. 링크를 사용하는 것은 내장된 객체를 사용하는 것보다 인체 공학적이지 않으므로(less ergonomic), 가능하다면 임베드된 객체를 사용해야 합니다. @@ -23,14 +25,14 @@ title: 링크 ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teachers.save(); @@ -91,7 +93,7 @@ isar.writeTxnSync(() { ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -113,7 +115,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/ko/queries.md b/docs/docs/ko/queries.md index 64768e60f..d6447f1c2 100644 --- a/docs/docs/ko/queries.md +++ b/docs/docs/ko/queries.md @@ -25,7 +25,7 @@ title: 쿼리 ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -201,7 +201,7 @@ final shoes2 = await isar.shoes.filter() ```dart class Tweet { - Id? id; + late int id; String? text; @@ -238,7 +238,7 @@ final flutterTweets = await isar.tweets.filter() ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -283,14 +283,14 @@ Isar 는 링크된 객체를 조회해야 하므로 링크 쿼리의 비용은 ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -342,7 +342,7 @@ filter 와 달리 where 절은 쿼리 조건을 검사하기 위해서 스키마 ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/ko/recipes/data_migration.md b/docs/docs/ko/recipes/data_migration.md index e1f8552ff..aef49b79d 100644 --- a/docs/docs/ko/recipes/data_migration.md +++ b/docs/docs/ko/recipes/data_migration.md @@ -19,7 +19,7 @@ Isar 는 컬렉션, 속성, 인덱스를 추가하거나 삭제하면 데이터 ```dart @collection class User { - Id? id; + late int id; late String name; @@ -32,7 +32,7 @@ class User { ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/ko/recipes/full_text_search.md b/docs/docs/ko/recipes/full_text_search.md index f00334ae9..a8b4834ea 100644 --- a/docs/docs/ko/recipes/full_text_search.md +++ b/docs/docs/ko/recipes/full_text_search.md @@ -24,7 +24,7 @@ Let's create the most basic full-text index: ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ Easy peasy! We can change our index also to support prefix matching and case-ins ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ Sure thing! We will use a trick to achieve `.endsWith()` matching: ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/ko/schema.md b/docs/docs/ko/schema.md index dc98bb3c3..169db86db 100644 --- a/docs/docs/ko/schema.md +++ b/docs/docs/ko/schema.md @@ -17,7 +17,7 @@ title: 스키마 ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -79,7 +79,7 @@ Isar 는 컬렉션 클래스의 모든 public 필드를 저장합니다. 속성 ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -100,7 +100,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -156,7 +156,7 @@ Isar 는 아래의 데이터 타입들을 지원합니다: ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -217,7 +217,7 @@ Isar는 다른 Isar 타입들 처럼 열거형을 저장하고 사용할 수 있 ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // EnumType.ordinal 과 같습니다. late TestEnum byteIndex; // 널이 될 수 없습니다. @@ -255,7 +255,7 @@ enum TestEnum { ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/ko/transactions.md b/docs/docs/ko/transactions.md index cb74db49c..8290eca0b 100644 --- a/docs/docs/ko/transactions.md +++ b/docs/docs/ko/transactions.md @@ -15,8 +15,8 @@ Isar 에서 트랜잭션은 단일 작업 단위 안에서 여러 데이터베 | | 읽기 | 읽기 & 쓰기 | | ------ | ------------ | ----------------- | -| 동기 | `.txnSync()` | `.writeTxnSync()` | -| 비동기 | `.txn()` | `.writeTxn()` | +| 동기 | `.read()` | `.write()` | +| 비동기 | `.readAsync()` | `.writeAsync()` | ### 읽기 트랜잭션 @@ -39,13 +39,13 @@ Isar 에서 트랜잭션은 단일 작업 단위 안에서 여러 데이터베 ```dart @collection class Contact { - Id? id; + late int id; String? name; } // GOOD -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -53,7 +53,7 @@ await isar.writeTxn(() async { // BAD: 트랜잭션 안으로 for 루프를 이동시키세요. for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/links.md b/docs/docs/links.md index 178fd4fcd..876716b90 100644 --- a/docs/docs/links.md +++ b/docs/docs/links.md @@ -2,6 +2,8 @@ title: Links --- +> ⚠️ Links are currently not supported in Isar v4 + # Links Links allow you to express relationships between objects, such as a comment's author (User). You can model `1:1`, `1:n`, and `n:n` relationships with Isar links. Using links is less ergonomic than using embedded objects, and you should use embedded objects whenever possible. @@ -23,14 +25,14 @@ For non-web targets, links get loaded automatically when you use them for the fi ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teacher.save(); @@ -91,7 +93,7 @@ Internally both `IsarLink` and `IsarLinks` are represented in the same way. We c ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -113,7 +115,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/pt/crud.md b/docs/docs/pt/crud.md index 1d8fa310a..e2e64277e 100644 --- a/docs/docs/pt/crud.md +++ b/docs/docs/pt/crud.md @@ -47,7 +47,7 @@ Para os exemplos abaixo, assumimos que temos uma coleção `Recipe` definida da ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -114,7 +114,7 @@ final favouires = await isar.recipes.filter() Finalmente chegou a hora de modificar nossa coleção! Para criar, atualizar ou excluir objetos, use as respectivas operações envolvidas em uma transação de gravação: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await isar.recipes.get(123) recipe.isFavorite = false; @@ -134,11 +134,12 @@ Se o campo id for `null` ou `Isar.autoIncrement`, Isar usará um id de increment ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.put(pancakes); }) ``` @@ -148,7 +149,7 @@ Isar atribuirá automaticamente o id ao objeto se o campo `id` não for final. Inserir vários objetos de uma só vez é extremamente fácil: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.putAll([pancakes, pizza]); }) ``` @@ -160,7 +161,7 @@ Tanto a criação quanto a atualização funcionam com `collection.put(object)`. Então, se quisermos desfavoritar nossas panquecas, podemos fazer o seguinte: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await isar.recipes.put(recipe); }); @@ -171,7 +172,7 @@ await isar.writeTxn(() async { Quer se livrar de um objeto em Isar? Use `collection.delete(id)`. O método delete retorna se um objeto com o id especificado foi encontrado e excluído. Se você quiser excluir o objeto com id `123`, por exemplo, você pode fazer: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await isar.recipes.delete(123); print('Receita apagada: $success'); }); @@ -180,7 +181,7 @@ await isar.writeTxn(() async { Da mesma forma para obter e colocar, também há uma operação de exclusão em massa que retorna o número de objetos excluídos: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.deleteAll([1, 2, 3]); print('Apagamos $count receitas'); }); @@ -189,7 +190,7 @@ await isar.writeTxn(() async { Se você não souber os ids dos objetos que deseja excluir, poderá usar uma consulta: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/pt/indexes.md b/docs/docs/pt/indexes.md index 59df92f7d..6fbd4f474 100644 --- a/docs/docs/pt/indexes.md +++ b/docs/docs/pt/indexes.md @@ -15,7 +15,7 @@ Por exemplo, esta coleção `Product` é totalmente desordenada. ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ Para melhorar o desempenho desta consulta, indexamos a propriedade `price`. Um ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ Um índice único garante que o índice não contenha valores duplicados. Pode c ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ print(await isar.user.where().findAll()); ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ Todos os índices nas propriedades `String` e `List` diferenciam maiúsc ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ Provavelmente é melhor começar com um exemplo. Criamos uma coleção de pessoa ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ As aplicações práticas para índices de várias entradas incluem a indexaçã ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/pt/links.md b/docs/docs/pt/links.md index 2d88f91a9..9696bd2b2 100644 --- a/docs/docs/pt/links.md +++ b/docs/docs/pt/links.md @@ -2,6 +2,8 @@ title: Links --- +> ⚠️ Links are currently not supported in Isar v4 + # Links Os links permitem que você expresse relacionamentos entre objetos, como o autor de um comentário (Usuário). Você pode modelar relacionamentos `1:1`, `1:n` e `n:n` com links Isar. Usar links é menos ergonômico do que usar objetos incorporados e você deve usar objetos incorporados sempre que possível. @@ -22,14 +24,14 @@ Para destinos não Web, os links são carregados automaticamente quando você os ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -48,7 +50,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teacher.save(); @@ -90,7 +92,7 @@ Internamente, `IsarLink` e `IsarLinks` são representados da mesma maneira. Pode ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -112,7 +114,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/pt/queries.md b/docs/docs/pt/queries.md index 782934eb7..d82f618df 100644 --- a/docs/docs/pt/queries.md +++ b/docs/docs/pt/queries.md @@ -25,7 +25,7 @@ We'll use the following model for the examples below: ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -198,7 +198,7 @@ Even lists can be queried: ```dart class Tweet { - Id? id; + late int id; String? text; @@ -235,7 +235,7 @@ Embedded objects are one of Isar's most useful features. They can be queried ver ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -280,14 +280,14 @@ Keep in mind that link queries can be expensive because Isar needs to look up li ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -339,7 +339,7 @@ Let's add indexes to the shoe collection: ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/pt/schema.md b/docs/docs/pt/schema.md index c65a8b9fd..e0a828d46 100644 --- a/docs/docs/pt/schema.md +++ b/docs/docs/pt/schema.md @@ -17,7 +17,7 @@ The following code is an example of a simple collection that defines a `User` ta ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar persists all public fields of a collection class. By annotating a property ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -155,7 +155,7 @@ Here is an example collection containing all of the above types: ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -216,7 +216,7 @@ Let's check out an example for each strategy. ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // same as EnumType.ordinal late TestEnum byteIndex; // cannot be nullable @@ -254,7 +254,7 @@ It's often helpful to have nested objects in your collection model. There is no ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/pt/transactions.md b/docs/docs/pt/transactions.md index 90be41c38..32b335989 100644 --- a/docs/docs/pt/transactions.md +++ b/docs/docs/pt/transactions.md @@ -14,10 +14,10 @@ As transações (especialmente transações de gravação) têm um custo e você As transações podem ser síncronas ou assíncronas. Em transações síncronas, você só pode usar operações síncronas. Em transações assíncronas, apenas operações assíncronas. -| | Read | Read & Write | -|--------------|--------------|--------------------| -| Synchronous | `.txnSync()` | `.writeTxnSync()` | -| Asynchronous | `.txn()` | `.writeTxn()` | +| | Read | Read & Write | +|--------------|----------------|------------------| +| Synchronous | `.read()` | `.write()` | +| Asynchronous | `.readAsync()` | `.writeAsync()` | ### Transações de leitura @@ -41,13 +41,13 @@ Quando uma operação de banco de dados falha, a transação é abortada e não ```dart @collection class Contact { - Id? id; + late int id; String? name; } // GOOD -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -55,7 +55,7 @@ await isar.writeTxn(() async { // BAD: move loop inside transaction for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/queries.md b/docs/docs/queries.md index 2f039dc18..c3acd4eec 100644 --- a/docs/docs/queries.md +++ b/docs/docs/queries.md @@ -25,7 +25,7 @@ We'll use the following model for the examples below: ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -198,7 +198,7 @@ Even lists can be queried: ```dart class Tweet { - Id? id; + late int id; String? text; @@ -235,7 +235,7 @@ Embedded objects are one of Isar's most useful features. They can be queried ver ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -280,14 +280,14 @@ Keep in mind that link queries can be expensive because Isar needs to look up li ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -339,7 +339,7 @@ Let's add indexes to the shoe collection: ```dart @collection class Shoe { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/recipes/data_migration.md b/docs/docs/recipes/data_migration.md index b89643c17..3b9797d9c 100644 --- a/docs/docs/recipes/data_migration.md +++ b/docs/docs/recipes/data_migration.md @@ -18,7 +18,7 @@ Version 1: ```dart @collection class User { - Id? id; + late int id; late String name; @@ -30,7 +30,7 @@ Version 2: ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/recipes/full_text_search.md b/docs/docs/recipes/full_text_search.md index f00334ae9..a8b4834ea 100644 --- a/docs/docs/recipes/full_text_search.md +++ b/docs/docs/recipes/full_text_search.md @@ -24,7 +24,7 @@ Let's create the most basic full-text index: ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ Easy peasy! We can change our index also to support prefix matching and case-ins ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ Sure thing! We will use a trick to achieve `.endsWith()` matching: ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/schema.md b/docs/docs/schema.md index c65a8b9fd..e0a828d46 100644 --- a/docs/docs/schema.md +++ b/docs/docs/schema.md @@ -17,7 +17,7 @@ The following code is an example of a simple collection that defines a `User` ta ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar persists all public fields of a collection class. By annotating a property ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -155,7 +155,7 @@ Here is an example collection containing all of the above types: ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -216,7 +216,7 @@ Let's check out an example for each strategy. ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // same as EnumType.ordinal late TestEnum byteIndex; // cannot be nullable @@ -254,7 +254,7 @@ It's often helpful to have nested objects in your collection model. There is no ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/transactions.md b/docs/docs/transactions.md index 1c5eb375e..5839d1dd5 100644 --- a/docs/docs/transactions.md +++ b/docs/docs/transactions.md @@ -14,10 +14,10 @@ Transactions (especially write transactions) do have a cost, and you should alwa Transactions can either be synchronous or asynchronous. In synchronous transactions, you may only use synchronous operations. In asynchronous transactions, only async operations. -| | Read | Read & Write | -| ------------ | ------------ | ----------------- | -| Synchronous | `.txnSync()` | `.writeTxnSync()` | -| Asynchronous | `.txn()` | `.writeTxn()` | +| | Read | Read & Write | +| ------------ | -------------- | --------------- | +| Synchronous | `.read()` | `.write()` | +| Asynchronous | `.readAsync()` | `.writeAsync()` | ### Read transactions @@ -40,13 +40,13 @@ When a database operation fails, the transaction is aborted and must no longer b ```dart @collection class Contact { - Id? id; + late int id; String? name; } // GOOD -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -54,7 +54,7 @@ await isar.writeTxn(() async { // BAD: move loop inside transaction for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/ur/crud.md b/docs/docs/ur/crud.md index 3fde27146..3490e3322 100644 --- a/docs/docs/ur/crud.md +++ b/docs/docs/ur/crud.md @@ -48,7 +48,7 @@ final isar = await Isar.open( ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -111,7 +111,7 @@ final favouires = await isar.recipes.filter() آخر کار ہمارے کلیکشن میں ترمیم کرنے کا وقت آگیا ہے! اوبجیکٹس بنانے، اپ ڈیٹ کرنے یا حذف کرنے کے لیے، تحریری لین دین میں لپیٹے ہوئے متعلقہ آپریشنز کا استعمال کریں: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await isar.recipes.get(123) recipe.isFavorite = false; @@ -131,11 +131,12 @@ await isar.writeTxn(() async { ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.put(pancakes); }) ``` @@ -145,7 +146,7 @@ await isar.writeTxn(() async { ایک ساتھ متعدد اشیاء کو داخل کرنا اتنا ہی آسان ہے: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.putAll([pancakes, pizza]); }) ``` @@ -157,7 +158,7 @@ await isar.writeTxn(() async { لہذا اگر ہم اپنے پان کیکس کو ناپسند کرنا چاہتے ہیں، تو ہم درج ذیل کام کر سکتے ہیں: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await isar.recipes.put(recipe); }); @@ -167,7 +168,7 @@ await isar.writeTxn(() async { ایزار میں کسی چیز سے چھٹکارا حاصل کرنا چاہتے ہیں؟ `کلیکشن.ڈیلیٹ(آئی ڈی)` استعمال کریں۔ حذف کرنے کا طریقہ واپس کرتا ہے کہ آیا مخصوص آئی ڈی کے ساتھ کوئی آبجیکٹ ملا اور حذف کر دیا گیا تھا۔ اگر آپ آئی ڈی `123` کے ساتھ آبجیکٹ کو حذف کرنا چاہتے ہیں، مثال کے طور پر، آپ یہ کر سکتے ہیں: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await isar.recipes.delete(123); print('Recipe deleted: $success'); }); @@ -176,7 +177,7 @@ await isar.writeTxn(() async { اسی طرح حاصل کرنے اور ڈالنے کے لئے، ایک بلک ڈیلیٹ آپریشن بھی ہے جو حذف شدہ اشیاء کی تعداد لوٹاتا ہے: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -185,7 +186,7 @@ await isar.writeTxn(() async { اگر آپ ان اشیاء کی آئی ڈی نہیں جانتے جنہیں آپ حذف کرنا چاہتے ہیں، تو آپ ایک استفسار استعمال کر سکتے ہیں: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/ur/indexes.md b/docs/docs/ur/indexes.md index 245b5f206..f158d8c53 100644 --- a/docs/docs/ur/indexes.md +++ b/docs/docs/ur/indexes.md @@ -15,7 +15,7 @@ For example, this `Product` collection is entirely unordered. ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ final expensiveProducts = await isar.products.filter() ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ The `.anyX()` where clause tells Isar to use an index just for sorting. You can ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ print(await isar.user.where().findAll()); ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ All indexes on `String` and `List` properties are case-sensitive by defa ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ Use `IndexType.hashElements` for `List` where you need `elementEqualTo` ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ If you index a list using `IndexType.value`, Isar خود بخود ملٹی ان ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/ur/links.md b/docs/docs/ur/links.md index 5ffa54050..8eaf527a7 100644 --- a/docs/docs/ur/links.md +++ b/docs/docs/ur/links.md @@ -2,6 +2,8 @@ title: لنکس --- +> ⚠️ Links are currently not supported in Isar v4 + # لنکس روابط آپ کو اشیاء کے درمیان تعلقات کا اظہار کرنے کی اجازت دیتے ہیں، جیسے کہ تبصرہ کا مصنف (صارف)۔ آپ ای زار لنکس کے ساتھ `1:1`، `1:n`، اور `n:n` تعلقات کو ماڈل بنا سکتے ہیں۔ لنکس کا استعمال ایمبیڈڈ اشیاء کے استعمال سے کم ایرگونومک ہے اور جب بھی ممکن ہو آپ کو ایمبیڈڈ اشیاء کا استعمال کرنا چاہیے۔ @@ -23,14 +25,14 @@ Links are lazy, so you need to tell the `IsarLink` to load or save the `value` e ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teachers.save(); @@ -91,7 +93,7 @@ Internally both `IsarLink` and `IsarLinks` are represented in the same way. We c ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -113,7 +115,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/ur/queries.md b/docs/docs/ur/queries.md index bcb22fbdf..72f446c22 100644 --- a/docs/docs/ur/queries.md +++ b/docs/docs/ur/queries.md @@ -25,7 +25,7 @@ title: سوالات ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -198,7 +198,7 @@ final shoes2 = await isar.shoes.filter() ```dart class Tweet { - Id? id; + late int id; String? text; @@ -235,7 +235,7 @@ This is equivalent to the Dart code `tweets.where((t) => t.hashtags.contains('fl ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -280,14 +280,14 @@ final germanCars = await isar.cars.filter() ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -339,7 +339,7 @@ final result = await isar.students.filter().teachersIsEmpty().findAll(); ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/ur/recipes/data_migration.md b/docs/docs/ur/recipes/data_migration.md index fffa5f8dc..0484e2eb4 100644 --- a/docs/docs/ur/recipes/data_migration.md +++ b/docs/docs/ur/recipes/data_migration.md @@ -20,7 +20,7 @@ Version 1: ```dart @collection class User { - Id? id; + late int id; late String name; @@ -32,7 +32,7 @@ Version 2: ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/ur/recipes/full_text_search.md b/docs/docs/ur/recipes/full_text_search.md index 59765ef56..4d4771a42 100644 --- a/docs/docs/ur/recipes/full_text_search.md +++ b/docs/docs/ur/recipes/full_text_search.md @@ -24,7 +24,7 @@ You can easily search text using filters. There are various string operations fo ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ Isar.splitWords('The quick (“brown”) fox can’t jump 32.3 feet, right?'); ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ Sure thing! We will use a trick to achieve `.endsWith()` matching: ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/ur/schema.md b/docs/docs/ur/schema.md index f522741e5..14db4afe1 100644 --- a/docs/docs/ur/schema.md +++ b/docs/docs/ur/schema.md @@ -17,7 +17,7 @@ title: اسکیما ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar persists all public fields of a collection class. By annotating a property ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -149,7 +149,7 @@ Here is an example collection containing all of the above types: ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -210,7 +210,7 @@ Isar does not store timezone information of your dates. Instead, it converts `Da ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // same as EnumType.ordinal late TestEnum byteIndex; // cannot be nullable @@ -248,7 +248,7 @@ enum TestEnum { ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/ur/transactions.md b/docs/docs/ur/transactions.md index 8b6fe0e93..84ccdef6e 100644 --- a/docs/docs/ur/transactions.md +++ b/docs/docs/ur/transactions.md @@ -16,8 +16,8 @@ title: لین دین | | Read | Read & Write | |--------------|--------------|--------------------| -| Synchronous | `.txnSync()` | `.writeTxnSync()` | -| Asynchronous | `.txn()` | `.writeTxn()` | +| Synchronous | `.read()` | `.write()` | +| Asynchronous | `.readAsync()` | `.writeAsync()` | ### لین دین پڑھیں @@ -41,13 +41,13 @@ title: لین دین ```dart @collection class Contact { - Id? id; + late int id; String? name; } // GOOD -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -55,7 +55,7 @@ await isar.writeTxn(() async { // BAD: move loop inside transaction for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); } diff --git a/docs/docs/zh/crud.md b/docs/docs/zh/crud.md index 462df46c2..1ab788060 100644 --- a/docs/docs/zh/crud.md +++ b/docs/docs/zh/crud.md @@ -47,7 +47,7 @@ final isar = await Isar.open( ```dart @collection class Recipe { - Id? id; + late int id; String? name; @@ -114,7 +114,7 @@ final favouires = await isar.recipes.filter() 终于到了修改数据的时候了! 在一个写入事务(Write Transaction)中使用对应的操作序列来创建、修改和删除对象: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final recipe = await isar.recipes.get(123) recipe.isFavorite = false; @@ -134,11 +134,12 @@ await isar.writeTxn(() async { ```dart final pancakes = Recipe() + ..id = isar.recipes.autoIncrement() ..name = 'Pancakes' ..lastCooked = DateTime.now() ..isFavorite = true; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.put(pancakes); }) ``` @@ -148,7 +149,7 @@ await isar.writeTxn(() async { 同时插入多个对象也很简单: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.recipes.putAll([pancakes, pizza]); }) ``` @@ -160,7 +161,7 @@ await isar.writeTxn(() async { 所以如果我们想要取消喜欢煎饼的话,可以做以下操作: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { pancakes.isFavorite = false; await isar.recipes.put(recipe); }); @@ -171,7 +172,7 @@ await isar.writeTxn(() async { 想要从 Isar 数据库中删除一个对象?用 `collection.delete(id)` 方法。这个方法会返回指定对象是否被删除(即返回布尔值)。如果你想通过 Id 来删除指定菜单,比如其 Id 为 `123`,你可以用下方代码: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final success = await isar.recipes.delete(123); print('Recipe deleted: $success'); }); @@ -180,7 +181,7 @@ await isar.writeTxn(() async { 相似地,也有对应的批量删除方法,其返回结果是被删除对象的数量: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.deleteAll([1, 2, 3]); print('We deleted $count recipes'); }); @@ -189,7 +190,7 @@ await isar.writeTxn(() async { 如果你不知道你想删除对象的 Id,你可以先通过指定条件来查询: ```dart -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { final count = await isar.recipes.filter() .isFavoriteEqualTo(false) .deleteAll(); diff --git a/docs/docs/zh/indexes.md b/docs/docs/zh/indexes.md index d047b4d54..3a828ddbb 100644 --- a/docs/docs/zh/indexes.md +++ b/docs/docs/zh/indexes.md @@ -15,7 +15,7 @@ title: 索引 ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -50,7 +50,7 @@ final expensiveProducts = await isar.products.filter() ```dart @collection class Product { - Id? id; + late int id; late String name; @@ -110,7 +110,7 @@ final cheapestFast = await isar.products.where() ```dart @collection class User { - Id? id; + late int id; @Index(unique: true) late String username; @@ -147,7 +147,7 @@ print(await isar.user.where().findAll()); ```dart @collection class User { - Id? id; + late int id; @Index(unique: true, replace: true) late String username; @@ -206,7 +206,7 @@ await isar.user.where().findAll(); // -> [{id: 1, username: 'user1' age: 30}] ```dart @collection class Person { - Id? id; + late int id; @Index(caseSensitive: false) late String name; @@ -255,7 +255,7 @@ class Person { ```dart @collection class Person { - Id? id; + late int id; late String name; @@ -320,7 +320,7 @@ final result = await isar.where() ```dart @collection class Product { - Id? id; + late int id; late String description; diff --git a/docs/docs/zh/links.md b/docs/docs/zh/links.md index 2982ccb87..0dfeb07a4 100644 --- a/docs/docs/zh/links.md +++ b/docs/docs/zh/links.md @@ -2,6 +2,8 @@ title: 关联 --- +> ⚠️ Links are currently not supported in Isar v4 + # 关联(Link) 关联允许你表达对象之间的关系,比如评论的作者(即用户)。你可以使用 Isar 的关联来实现 `1:1`、`1:n` 和 `n:n` 的关系。使用关联比使用嵌套对象更不符人类工程学,因此你应该尽可能使用嵌套对象来代替关联。 @@ -23,14 +25,14 @@ title: 关联 ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -49,7 +51,7 @@ final linda = Student() ..name = 'Linda' ..teacher.value = mathTeacher; -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await isar.students.put(linda); await isar.teachers.put(mathTeacher); await linda.teacher.save(); @@ -91,7 +93,7 @@ isar.writeTxnSync(() { ```dart @collection class Student { - Id? id; + late int id; late String name; @@ -113,7 +115,7 @@ print(linda.teachers); // {Teacher('Math')} linda.teachers.add(biologyTeacher); -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { await linda.teachers.save(); }); diff --git a/docs/docs/zh/queries.md b/docs/docs/zh/queries.md index c94c05990..2283add9c 100644 --- a/docs/docs/zh/queries.md +++ b/docs/docs/zh/queries.md @@ -25,7 +25,7 @@ Filter 通过特定条件表达式来匹配 Collection 中每一个待查询对 ```dart @collection class Shoe { - Id? id; + late int id; int? size; @@ -198,7 +198,7 @@ final shoes2 = await isar.shoes.filter() ```dart class Tweet { - Id? id; + late int id; String? text; @@ -235,7 +235,7 @@ final flutterTweets = await isar.tweets.filter() ```dart @collection class Car { - Id? id; + late int id; Brand? brand; } @@ -280,14 +280,14 @@ final germanCars = await isar.cars.filter() ```dart @collection class Teacher { - Id? id; + late int id; late String subject; } @collection class Student { - Id? id; + late int id; late String name; @@ -339,7 +339,7 @@ Where 子句很强大,但是用对可能有点困难。 ```dart @collection class Shoe with IsarObject { - Id? id; + late int id; @Index() Id? size; diff --git a/docs/docs/zh/recipes/data_migration.md b/docs/docs/zh/recipes/data_migration.md index 46206a85f..dba2a8c40 100644 --- a/docs/docs/zh/recipes/data_migration.md +++ b/docs/docs/zh/recipes/data_migration.md @@ -19,7 +19,7 @@ title: 数据迁移 ```dart @collection class User { - Id? id; + late int id; late String name; @@ -32,7 +32,7 @@ class User { ```dart @collection class User { - Id? id; + late int id; late String name; diff --git a/docs/docs/zh/recipes/full_text_search.md b/docs/docs/zh/recipes/full_text_search.md index 2072387ed..8dee5e4ac 100644 --- a/docs/docs/zh/recipes/full_text_search.md +++ b/docs/docs/zh/recipes/full_text_search.md @@ -24,7 +24,7 @@ title: 全文检索 ```dart class Message { - Id? id; + late int id; late String content; @@ -67,7 +67,7 @@ Isar.splitWords('The quick (“brown”) fox can’t jump 32.3 feet, right?'); ```dart class Post { - Id? id; + late int id; late String title; @@ -95,7 +95,7 @@ final posts = await isar.posts ```dart class Post { - Id? id; + late int id; late String title; diff --git a/docs/docs/zh/schema.md b/docs/docs/zh/schema.md index 27fb8bdbd..2ccd80507 100644 --- a/docs/docs/zh/schema.md +++ b/docs/docs/zh/schema.md @@ -17,7 +17,7 @@ title: Schema ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -78,7 +78,7 @@ Isar 会保存 Collection 类中所有的公开属性。如下例子所示,给 ```dart @collection class User { - Id? id; + late int id; String? firstName; @@ -99,7 +99,7 @@ class User { @Collection(ignore: {'profilePicture'}) class Member extends User { - Id? id; + late int id; String? firstName; @@ -155,7 +155,7 @@ Isar 支持以下数据类型: ```dart @collection class TestCollection { - Id? id; + late int id; late byte byteValue; @@ -216,7 +216,7 @@ Isar 不会保存日期类型数据中的时区信息。相反,它会在存储 ```dart @collection class EnumCollection { - Id? id; + late int id; @enumerated // 等价于 EnumType.ordinal late TestEnum byteIndex; // 不能为空值 @@ -254,7 +254,7 @@ enum TestEnum { ```dart @collection class Email { - Id? id; + late int id; String? title; diff --git a/docs/docs/zh/transactions.md b/docs/docs/zh/transactions.md index bf2c294bb..eb63a1816 100644 --- a/docs/docs/zh/transactions.md +++ b/docs/docs/zh/transactions.md @@ -16,8 +16,8 @@ title: 事务 | | 读取 | 读写 | | ---- | ------------ | ----------------- | -| 同步 | `.txnSync()` | `.writeTxnSync()` | -| 异步 | `.txn()` | `.writeTxn()` | +| 同步 | `.read()` | `.write()` | +| 异步 | `.readAsync()` | `.writeAsync()` | ### 读取事务 @@ -40,13 +40,13 @@ title: 事务 ```dart @collection class Contact { - Id? id; + late int id; String? name; } // 良好 -await isar.writeTxn(() async { +await isar.writeAsync((isar) async { for (var contact in getContacts()) { await isar.contacts.put(contact); } @@ -54,7 +54,7 @@ await isar.writeTxn(() async { // 不好:要将循环放到事务里面 for (var contact in getContacts()) { - await isar.writeTxn(() async { + await isar.writeAsync((isar) async { await isar.contacts.put(contact); }); }