2024-10-12 10:35:14 +00:00
|
|
|
# Sembast Persistent Service for Protevus
|
2020-02-15 23:43:59 +00:00
|
|
|
|
2022-01-04 12:03:52 +00:00
|
|
|
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_sembast?include_prereleases)
|
2021-06-21 06:16:06 +00:00
|
|
|
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
2024-07-07 15:02:49 +00:00
|
|
|
[![Discord](https://img.shields.io/discord/1060322353214660698)](https://discord.gg/3X6bxTUdCM)
|
2024-10-12 10:35:14 +00:00
|
|
|
[![License](https://img.shields.io/github/license/dart-backend/protevus)](https://github.com/dart-backend/protevus/tree/master/packages/sembast/LICENSE)
|
2021-06-21 06:16:06 +00:00
|
|
|
|
2024-10-12 10:35:14 +00:00
|
|
|
A plugin service that persist data to Sembast for Protevus framework.
|
2021-06-21 06:16:06 +00:00
|
|
|
|
|
|
|
## Installation
|
2020-02-15 23:43:59 +00:00
|
|
|
|
|
|
|
Add the following to your `pubspec.yaml`:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
dependencies:
|
2023-12-24 16:10:10 +00:00
|
|
|
angel3_sembast: ^8.0.0
|
2020-02-15 23:43:59 +00:00
|
|
|
```
|
|
|
|
|
2021-06-21 06:16:06 +00:00
|
|
|
## Usage
|
2020-02-15 23:43:59 +00:00
|
|
|
|
|
|
|
This library exposes one main class: `SembastService`.
|
|
|
|
|
2021-06-21 06:16:06 +00:00
|
|
|
### SembastService
|
2020-02-15 23:43:59 +00:00
|
|
|
|
|
|
|
This class interacts with a `Database` and `Store` (from `package:sembast`) and serializes data to and from Maps.
|
|
|
|
|
2021-06-21 06:16:06 +00:00
|
|
|
### Querying
|
2020-02-15 23:43:59 +00:00
|
|
|
|
|
|
|
You can query these services as follows:
|
|
|
|
|
2023-12-24 16:10:10 +00:00
|
|
|
```curl
|
2021-06-21 06:16:06 +00:00
|
|
|
/path/to/service?foo=bar
|
|
|
|
```
|
2020-02-15 23:43:59 +00:00
|
|
|
|
|
|
|
The above will query the database to find records where 'foo' equals 'bar'.
|
|
|
|
|
|
|
|
The former will sort result in ascending order of creation, and so will the latter.
|
|
|
|
|
|
|
|
```dart
|
2021-06-21 06:16:06 +00:00
|
|
|
List queried = await MyService.index({r"query": where.id(Finder(filter: Filter(...))));
|
2020-02-15 23:43:59 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Of course, you can use `package:sembast` queries. Just pass it as `query` within `params`.
|
|
|
|
|
|
|
|
See the tests for more usage examples.
|