platform/packages/orm/angel_orm_service/README.md

36 lines
1.3 KiB
Markdown
Raw Normal View History

2021-08-12 03:39:01 +00:00
# Angel3 ORM Service
2021-12-20 04:25:43 +00:00
![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_orm_servie?include_prereleases)
2021-06-18 10:29:49 +00:00
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
2021-12-20 04:25:43 +00:00
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_service/LICENSE)
2019-04-20 19:45:42 +00:00
2021-08-12 03:39:01 +00:00
Service implementation that wraps over Angel3 ORM Query classes.
2019-04-20 19:45:42 +00:00
2019-04-20 21:34:14 +00:00
## Installation
2021-08-12 03:39:01 +00:00
2019-04-20 21:34:14 +00:00
In your `pubspec.yaml`:
```yaml
dependencies:
2023-12-24 16:10:10 +00:00
angel3_orm_service: ^8.0.0
2019-04-20 21:34:14 +00:00
```
2019-04-20 19:45:42 +00:00
## Usage
2021-08-12 03:39:01 +00:00
2019-04-20 19:45:42 +00:00
Brief snippet (check `example/main.dart` for setup, etc.):
```dart
// Create an ORM-backed service.
var todoService = OrmService<int, Todo, TodoQuery>(
executor, () => TodoQuery(),
readData: (req, res) => todoSerializer.decode(req.bodyAsMap));
// Because we provided `readData`, the todoService can face the Web.
// **IMPORTANT: Providing the type arguments is an ABSOLUTE MUST, if your
// model has `int` ID's (this is the case when using `angel_orm_generator` and `Model`).
// **
app.use<int, Todo, OrmService<int, Todo, TodoQuery>>(
'/api/todos', todoService);
2021-08-12 03:39:01 +00:00
```