platform/README.md

23 lines
709 B
Markdown
Raw Normal View History

2017-01-29 20:23:53 +00:00
# relations
2017-01-30 02:39:11 +00:00
[![version 1.0.0-alpha](https://img.shields.io/badge/pub-v1.0.0--alpha-red.svg)](https://pub.dartlang.org/packages/angel_relations)
[![build status](https://travis-ci.org/angel-dart/relations.svg)](https://travis-ci.org/angel-dart/relations)
2017-01-29 20:23:53 +00:00
Database-agnostic relations between Angel services.
2017-01-30 02:39:11 +00:00
```dart
// Authors owning one book
app.service('authors').afterAll(
relations.hasOne('books', as: 'book', foreignKey: 'authorId'));
// Or multiple
app.service('authors').afterAll(
relations.hasMany('books', foreignKey: 'authorId'));
// Or, books belonging to authors
app.service('books').afterAll(relations.belongsTo('authors'));
```
Currently supports:
* `hasOne`
* `hasMany`
* `belongsTo`