dorm library

Warning: this library is experimental, and APIs are subject to change.

This library is to be used in conjunction with a server-side ORM implementation.

You can however acquire a small Dart test server, which mimics a Hibernate server to fetch and commit to a JSON based database.

This test server can be found here: https://github.com/frankpepermans/dorm_mockserver

For example:

// Define a fetch service, this can hook up to an existing server-side webservice
FetchService fetchService = new FetchService(url, port, serializer, handleConflictAcceptClient);

// Define an entity in Dart, this will need to match with a server-side entity via a DTO
// Classes like these can be easily generated on the server for the Dart client
@Ref('entities.person')
class Person extends MutableEntity {

 //---------------------------------
 //
 // Public properties
 //
 //---------------------------------

 //---------------------------------
 // refClassName
 //---------------------------------

 String get refClassName => 'entities.person';

 //---------------------------------
 // id
 //---------------------------------

 @Property(ID_SYMBOL, 'id')
 @Id()
 @NotNullable()
 @DefaultValue(0)
 @Immutable()
 DormProxy<int> _id;

 static const String ID = 'id';
 static const Symbol ID_SYMBOL = const Symbol('orm_domain.Person.id');

 int get id => _id.value;
 set id(int value) => _id.value = notifyPropertyChange(ID_SYMBOL, _id.value, value)

 //---------------------------------
 // name
 //---------------------------------

 @Property(NAME_SYMBOL, 'name')
 @LabelField()

 DormProxy<String> _name;

 static const String NAME = 'name';
 static const Symbol NAME_SYMBOL = const Symbol('orm_domain.Person.name');

 String get name => _name.value;
 set name(String value) => _name.value = notifyPropertyChange(NAME_SYMBOL, _name.value, value);

 //---------------------------------
 //
 // Constructor
 //
 //---------------------------------

 Person() : super() {
   EntityAssembler assembler = new EntityAssembler();

   _id = new DormProxy()
   ..property = 'id'
   ..propertySymbol = ID_SYMBOL;

   _name = new DormProxy()
   ..property = 'name'
   ..propertySymbol = NAME_SYMBOL;

   assembler.registerProxies(this, <DormProxy>[_id, _name]);
 }

 static Person construct() {
   return new Person();
 }

}

main() {
 fetchService.ormEntityLoad('Person').then(
   (ObservableList resultList) {
     resultList.forEach(
       (Person person) => print(person.name);
     );
   }
 );
}

Classes

Annotation
DefaultValue
DormCodeGen
DormProxy<T>
Entity
EntityAssembler
This class is a singleton, you may obtain the instance at any time in the following manner : [...]
EntityCodec<S extends List<Entity>, T extends String>
EntityDecoder<S extends List<Entity>, T extends String>
EntityEncoder<S extends List<Entity>, T extends String>
EntityFactory<T extends Entity>
EntityLazyHandler
EntityPostProcessor
EntityRootScan
EntityScan
Externalizable
Id
Immutable
LabelField
Lazy
MetadataCache
MetadataExternalized
MetadataValidationReason
MetadataValidationResult
NotNullable
Property
Ref
SerializationType
Serializer<T, U extends Map<String, dynamic>>
SerializerBase
SerializerJson<T, U extends Map<String, dynamic>>
SerializerMixin<T, U extends Map<String, dynamic>>
Silent
Transform
Transient

Constants

dorm → const Object
const DormCodeGen()
IS_LAZILY_LOADED → const Symbol
const Symbol('dorm.core.IsLazyLoaded')

Enums

ConflictManager

Typedefs

EntityCtor() Entity
LazyLoaderMethod(Entity entity, Symbol symbol) Future
OnConflictFunction(Entity serverEntity, Entity clientEntity) ConflictManager
PostProcessorMethod(Entity entity) → void

Exceptions / Errors

DormError