Siesta.js

An Object Graph framework for Javascript

Siesta is an object graph & life cycle management framework.In english - Siesta presents a robust and powerful mechanism for managing your models in the browser taking inspiration from awesome frameworks such as Apple'sCoreData.

Siesta is an attempt to address variousproblemswhen handling data in the browser, the most important being thesingle source of truth.

Expressive

var House = collection.model('House', {
  id: 'houseId',
  attributes: ['address'],
  relationships: {
    owner: {
      model: 'User',
      reverse: 'houses'
    }
  }
});

Express complex models and the relationships between them.

Simple

House.graph({
  houseId: 1,
  address:'10 Westminster Drive',
  owner: 10
}).then(function (house) {
  // ...
});

One function for creating and updating object by mapping arbitrary data onto the object graph.

Single Source of Truth

User.graph([
  {id: 5, username: 'mike'},
  {id: 5, email: 'mtford@gmail.com'})
]).then(function (users) {
  console.log(users[0] === users[1]); // True
  house.owner = mike;
  console.log(mike.houses[0] === house); // true
});

One object per resource. Automatically hook up related objects.

Powerful Queries

// Get all users aged between 20 and 30
Users
  .query({$or: {age__gte: 20, age__lte: 30}})
  .then(function (users) {
     // ...
  });f

Query your app's object graph in interesting and powerful ways.

Reactive Programming

Users
  .on('new', function (user) {
      // Called on user creation
  })
  .query({$or: {age__gte: 20, age__lte: 30}})
  .on('new', function (e) {
      // Fired whenever a new user matching the query is created.
   });

React to changes in the object graph.

Local Persistence

Users
  .graph([
      {id: 1, username: 'mike'},
      {id: 2, username: 'bob'}
   ]).then(function (users) {
      Users.save();
   });

Backed by PouchDB allowing you to store the object graph in a multitude of browser-storage solutions.