Angel, like many other Web server frameworks, features support for object-relational mapping,or ORM. ORM tools allow for conversion from database results to Dart classes.

    Angel’s ORM uses Dart’s build system to generate query builder classes from your Model classes,and takes advantage of Dart’s strong typing to prevent errors at runtime.

    Take, for example, the following class:

    1. @orm
    2. abstract class _Pokemon extends Model {
    3. String get nickName;
    4. int get level;
    5. int get experiencePoints;
    6. @belongsTo
    7. PokemonTrainer get trainer;
    8. @belongsTo
    9. PokemonSpecies get species;
    10. @belongsTo
    11. PokemonAttack get attack0;
    12. @belongsTo
    13. PokemonAttack get attack2;
    14. @belongsTo
    15. PokemonAttack get attack3;
    16. @belongsTo
    17. PokemonAttack get attack4;
    18. }

    package:angel_orm_generator will generate code that letsyou do the following:

    1. app.get('/trainer/int:id/first_moves', (req, res) async {
    2. var id = req.params['id'] as int;
    3. var executor = req.container.make<QueryExecutor>();
    4. var trainer = await findTrainer(id);
    5. var query = PokemonQuery()..where.trainerId.equals(id);
    6. var pokemon = await query.get(executor);
    7. return pokemon.map((p) => p.attack0.name).toList();
    8. });

    This section of the Angel documentation consists mostly ofguides, rather than technical documentation.

    For more in-depth documentation, see the actualangel_orm project on Github:

    https://github.com/angel-dart/orm