For the complete documentation index, see llms.txt. This page is also available as Markdown.

Basic Functionality

Before starting with the ORM, it is highly recommended to familiar one's self with package:angel3_serialize, as it is the foundation for package:angel3_orm:

https://github.com/dukefirehawk/angel/tree/master/packages/serialize

To enable the ORM for a given model, simply add the @orm annotation to its definition:

@orm
@serializable
abstract class _Todo {
    bool get isComplete;

    String get text;

    @Column(type: ColumnType.long)
    int get score;
}

The generator will produce a TodoQuery class, which contains fields corresponding to each field declared in _Todo. Each of TodoQuery's fields is a subclass of SqlExpressionBuilder, corresponding to the given type. For example, TodoQuery would look something like:

class TodoQuery extends Query<Todo, TodoQueryWhere> {
    BooleanSqlExpressionBuilder get isComplete;

    StringSqlExpressionBuilder get text;

    NumericSqlExpressionBuilder<int> get score;
}

Thus, you can query the database using plain-old-Dart-objects (PODO's):

The glue holding everything together is the QueryExecutor interface. To support the ORM for any arbitrary database, simply extend the class and implement its abstract methods.

Consumers of a QueryExecutor typically inject it into the app's dependency injection container:

At the time of this writing, there is only support for PostgreSQL, though more databases may be added eventually.

Last updated