Skip to content

Commit

Permalink
doc fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
anidotnet committed Jan 4, 2024
1 parent c54db01 commit 8a56ba2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion flutter-sdk/repository/entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ mixin _$BookEntityMixin implements NitriteEntity {
While creating or opening a repository, you can pass an instance of `EntityDecorator` to the `getRepository()` method on `Nitrite` class. Nitrite will extract the metadata from the `EntityDecorator` instance and use it to create the repository.

```dart
ObjectRepository<Product> repository = db.getRepository<Product>(entityDecorator: ProductDecorator());
ObjectRepository<Product> repository = await db.getRepository<Product>(entityDecorator: ProductDecorator());
```

To write an `EntityDecorator` for an entity, you need to implement the `EntityDecorator` interface. Let's take an example of a `Product` entity.
Expand Down
8 changes: 4 additions & 4 deletions flutter-sdk/repository/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ There are several options available to create a repository. You can pass a class
You can create a `ObjectRepository` by passing a class type to `getRepository()` method.

```dart
ObjectRepository<Employee> repository = db.getRepository<Employee>();
ObjectRepository<Employee> repository = await db.getRepository<Employee>();
```

### Creating a Repository with Class Type and Key

You can create a keyed `ObjectRepository` by passing a class type and a key to `getRepository()` method.

```dart
ObjectRepository<Employee> repository = db.getRepository<Employee>(key: "myKey");
ObjectRepository<Employee> repository = await db.getRepository<Employee>(key: "myKey");
```

One typical use case of this keyed repository is to create a repository for each user in a multi-user application. The key can be the user name or user id. This will ensure that each user will have a separate repository for storing objects.
Expand All @@ -38,7 +38,7 @@ A `ObjectRepository` can be created using `EntityDecorator`. This is useful when
More details about `EntityDecorator` can be found [here](entity.md#entitydecorator).

```dart
ObjectRepository<Employee> repository = db.getRepository<Employee>(entityDecorator: EmployeeDecorator());
ObjectRepository<Employee> repository = await db.getRepository<Employee>(entityDecorator: EmployeeDecorator());
```

### Creating a Repository with EntityDecorator and Key
Expand All @@ -48,6 +48,6 @@ A keyed `ObjectRepository` can be created using `EntityDecorator` and a key. Thi
More details about `EntityDecorator` can be found [here](entity.md#entitydecorator).

```dart
ObjectRepository<Employee> repository = db.getRepository<Employee>(entityDecorator: EmployeeDecorator(), key: "myKey");
ObjectRepository<Employee> repository = await db.getRepository<Employee>(entityDecorator: EmployeeDecorator(), key: "myKey");
```

0 comments on commit 8a56ba2

Please sign in to comment.