relations

version 1.0.1build status

Database-agnostic relations between Angel services.

  1. // Authors owning one book
  2. app.service('authors').afterAll(
  3. relations.hasOne('books', as: 'book', foreignKey: 'authorId'));
  4.  
  5. // Or multiple
  6. app.service('authors').afterAll(
  7. relations.hasMany('books', foreignKey: 'authorId'));
  8.  
  9. // Or, books belonging to authors
  10. app.service('books').afterAll(relations.belongsTo('authors'));

Supports:

  • hasOne
  • hasMany
  • hasManyThrough
  • belongsTo
  • belongsToMany