ManagedContext class

A service object that handles connecting to and sending queries to a database.

You create objects of this type to use the Aqueduct ORM. Create instances in ApplicationChannel.prepare and inject them into controllers that execute database queries.

A context contains two types of objects:

Example usage:

    class Channel extends ApplicationChannel {
       ManagedContext context;

       Future prepare() async {
          var store = new PostgreSQLPersistentStore(...);
          var dataModel = new ManagedDataModel.fromCurrentMirrorSystem();
          context = new ManagedContext(dataModel, store);

       Controller get entryPoint {
         final router = new Router();
         router.route("/path").link(() => new DBController(context));
         return router;
Implemented types


ManagedContext(ManagedDataModel dataModel, PersistentStore persistentStore)
Creates an instance of ManagedContext from a ManagedDataModel and PersistentStore. [...]
ManagedContext.childOf(ManagedContext parentContext)
Creates a child context from parentContext.


dataModel ManagedDataModel
The data model containing the ManagedEntitys that describe the ManagedObjects this instance works with.
persistentStore PersistentStore
The persistent store that Querys on this context are executed through.
read / write
hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited


close() → Future
Closes this context and release its underlying resources. [...]
documentComponents(APIDocumentContext context) → void
Tells this object to add its components to context. [...]
entityForType(Type type) ManagedEntity
Returns an entity for a type from dataModel. [...]
fetchObjectWithID<T extends ManagedObject>(dynamic identifier) → Future<T>
Returns an object of type T from this context if it exists, otherwise returns null. [...]
insertObject<T extends ManagedObject>(T object) → Future<T>
Inserts a single object into this context. [...]
insertObjects<T extends ManagedObject>(List<T> objects) → Future<List<T>>
Inserts each object in objects into this context. [...]
transaction<T>(Future<T> transactionBlock(ManagedContext transaction)) → Future<T>
Runs all Querys in transactionBlock within a database transaction. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
toString() → String
Returns a string representation of this object.


operator ==(dynamic other) → bool
The equality operator.