package dorm

dorm

Dorm

Dorm is a client side library, it can he hooked up to a server side ORM implementation such as Hibernate for example.
The idea behind Dorm is that you expose your ORM entity model (or a subset of it) to your client application
and load and/or commit entities asynchronously via services.

Dorm is used and tested in a production application, the server-side implementation is not open sourced.
To set it up for example between Java Hibernate and :dart: is not difficult however.

The entities implement the Observable library to provide easy binding into frameworks such as Polymer.

Communication with the server currently works via JSON, both for sending and receiving entities,
but one can easily implement other message formats.
An Entity has readExternal and writeExternal methods which will iterate all values and get or insert them to or from a Map object.
This Map can them be converted to a message format of choice.

This rule will read the date as int value from the incoming JSON data,
and send out again the date as an int whenever the data is outgoing.

When Dorm submits changes to its entities, only properties that are dirty (changed on the client) will be serialized.

Serialization rules

Dorm needs to understand the serialized JSON when it comes to cyclic references,
one way for the server to support this, is by creating DTO's for your entities,
then when the serialization is needed, loop over the DTO and in doing so,
keep a reference to the entities that are already serialized.

If a cyclic reference is detected, then instead of serializing the DTO values, do this instead:

{
"?t":"path.to.entities.Foo", // the entity type, including the class path
"?p":true, // indicates that this is a cyclic reference
"foo_id":1 // primary key name and value
}