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;

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

       @override
       Controller get entryPoint {
         final router = new Router();
         router.route("/path").link(() => new DBController(context));
         return router;
       }
    }
Implements

Constructors

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.

Properties

dataModel ManagedDataModel
The data model containing the ManagedEntitys that describe the ManagedObjects this instance works with.
final
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

Methods

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. [...]
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. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited