Angel
Search…
About
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
5
int get level;
6
7
int get experiencePoints;
8
9
@belongsTo
10
PokemonTrainer get trainer;
11
12
@belongsTo
13
PokemonSpecies get species;
14
15
@belongsTo
16
PokemonAttack get attack0;
17
18
@belongsTo
19
PokemonAttack get attack2;
20
21
@belongsTo
22
PokemonAttack get attack3;
23
24
@belongsTo
25
PokemonAttack get attack4;
26
}
Copied!
package:angel_orm_generator will generate code that lets you 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
});
Copied!
This section of the Angel documentation consists mostly of guides, rather than technical documentation.
For more in-depth documentation, see the actual angel_orm project on Github:
Last modified 2yr ago
Copy link