chaos-orm
v19.0.7
Published
Datastore Agnostic Model Layer
Downloads
81
Readme
chaos-orm
Chaos is an independent, persistence-agnostic layer responsible for defining entities' business logic and relationships. It allows to describe a Domain Model without any assumption about the persistence layer.
Available datasources libraries:
Chaos dramatically simplify the developpment of a datasources libraries by providing all persistence-agnostic logic like relationships, eager loading at the root level. The only requirement is the datasource you envisionned to use need to be able to fetch a record/document thanks to a unique identifier (i.e no composite primary key).
Install
npm install chaos-orm
Note: Require babel-polyfill
as a peer dependency
Main Features
- Support eager loading
- Support nested saving
- Support external & embedded relationship
- Support custom types & entities' field casting
Example of syntax:
import co from 'co';
import Image from './model/Images';
co(function* () {
// Adding a many-to-many relation
var image = yield Image.load(123, { 'embed': 'tags' });
image.push({ name: 'Landscape' });
yield image.broadcast();
image.tags.forEach(function(tag) {
console.log(tag.get('name'));
}); // Echoes: 'Montain', 'Black&White', 'Landscape'
});
Documentation
See the whole documentation here.
Testing
The spec suite can be runned with:
cd chaos-orm
npm install
npm test