Class StorableObject

StorableObject is an object that can be persisted between requests.
Defined in: storage.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

A StorableObject is an object that can be persisted between requests.

Field Summary
Field Attributes Field Name and Description
<static>  
StorableObject.id
The id of a StorableObject is auto-generated and can't be changed.
Class Detail
StorableObject(obj)

A StorableObject is an object that can be persisted between requests.

To create a StorableObject, call new StorableObject().

You can optionally pass any JavaScript object to the constructor, and the properties and values of the object will become properties and values of the newly-created StorableObject, as in new StorableObject({username: "aiba", password: "sex"}).

StorableObjects are very similar to normal JavaScript objects, except that StorableObjects can't have properties that are functions. Properties that are objects must be StorableObjects, and assigning a normal JavaScript object will cause a StorableObject to be created (in other words, storage.foo = {a: 1} behaves like storage.foo = new StorableObject({a: 1})).

Once a StorableObject is constructed, it may be persisted in two different ways: You can assign it as the property of another StorableObject, such as the root StorableObject called storage. Or you can add it to a StorableCollection.

// Storing a string

var obj = new StorableObject();
obj.message = "Hi there!";
storage.foo = obj;
// Alternative code to do the same thing

storage.foo = new StorableObject({message: "Hi there!"});
// Adding StorableObjects to a StorableCollection

storage.people = new StorableCollection();

var person1 = new StorableObject({name: "Aaron", age: 25});
var person2 = new StorableObject({name: "David", age: 24});
var person3 = new StorableObject({name: "JD", age: 25});

storage.people.add(person1);
storage.people.add(person2);
storage.people.add(person3);
Parameters:
{object} obj Optional
An optional object whose properties will be copied into the returned StorableObject. obj cannot have any functions, and any properties of obj's prototype are ignored. Any objects that obj references will also be copied. (Note that because properties are copied, any subsequent modifications to obj will not be reflected in the returned StorableObject).
Field Detail
<static> {string} StorableObject.id
The id of a StorableObject is auto-generated and can't be changed. You can get the object associated with a given id using getStorable.

©2011 by JGate on AppJet
Documentation generated by JsDoc Toolkit 2.1.0 on Thu Jan 06 2011 10:36:33 GMT+0100 (MEZ)