platform/README.md
2017-01-29 21:39:11 -05:00

709 B

relations

version 1.0.0-alpha 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'));

Currently supports:

  • hasOne
  • hasMany
  • belongsTo