Types

There's two types of data structure in Spiritual EDB: edb.Object and edb.Array. They are commonly referred to as Types and they behave much like regular objects and arrays, except they can be observed for changes in browser that don't necessarily support Object.observe.

Both are constructors for a gui.Class and the syntax for declaring them resembles that of spirits and plugins (see gui.Class).

var Person = edb.Object.extend(/* extensions */);
var Persons = edb.Array.extend(/* extensions */);

Loading Types

Types are designed to be instantiated with JSON data. This will come in handy when we fetch the data from a server or from localStorage.

var person = new MyPerson({
	firstname: 'John',
	lastname: 'Johnson'
});

Saving Types

If you modify a Type instance, you might like to backup the data. Simply convert it back to JSON.

var guid = person.$id;
var json = JSON.stringify(person);
localStorage.setItem(guid, json);

Note about _ and $ properties.

Note about primary key.