ManagedContext class Null safety

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

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

A context contains two types of objects:

  • PersistentStore : Maintains a connection to a specific database. Transfers data between your application and the database.
  • ManagedDataModel : Contains information about the ManagedObject subclasses in your application.

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.
hashCode int
The hash code for this object. [...]
read-only, inherited
persistentStore PersistentStore?
The persistent store that Querys on this context are executed through.
read / write
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. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
A string representation of this object. [...]
transaction<T>(Future<T?> transactionBlock(ManagedContext transaction)) Future<T?>
Runs all Querys in transactionBlock within a database transaction. [...]


operator ==(Object other) bool
The equality operator. [...]