platform/packages/relations/README.md
Tobe O cad3b9c746 Add 'packages/relations/' from commit 'f1d7081f462d497a1d5810356132867158379e79'
git-subtree-dir: packages/relations
git-subtree-mainline: b1a6f262ea
git-subtree-split: f1d7081f46
2020-02-15 18:44:01 -05:00

731 B

relations

version 1.0.1 build status

Database-agnostic relations between Angel services.

// 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'));

Supports:

  • hasOne
  • hasMany
  • hasManyThrough
  • belongsTo
  • belongsToMany