Active Record for Javascript gives you persistence for your javascript applications with an Active Record twist.
From their docs...
Defining Your Model
ActiveRecord classes are created using the ActiveRecord.create method which takes three arguments: the name of the table that the class will reference, a field definition hash, and optionally a hash of instance methods that will be added to the class. If the table does not exist it will be automically created.
Class & Instance Methods
JavaScript does not have true static methods or classes, but in this case any method of the User variable above is refered to as a class method, and any method of a particular user (that the User class would find) is refered to as an instance method. The most important class methods are create() and find():
Add new class or instance methods to all ActiveRecord models in the following way:
Getters & Setters
It is extremely important to note that all of the attributes/columns of the user are accessible directly for reading (for convenience), but cannot be written directly. You must use the set() method to set an attribute, you should use the get() method to access all attributes, but you must use the get() method if your attribute/column is a method of the object or a JavaScript reserved keyword ('save,'initialize','default', etc).
When Data is Persisted
Data is only persisted to the database in three cases: when you explicitly call save() on a record, when you call create() on a record, or create a child record through a relationship (the method will contain the word "create" in this case), or when you call updateAttribute() on a record. In the case of the latter, only the attribute you update will be saved, the rest of the record will not be persisted to the database, even if changes have been made. Calling save() may add an "id" property to the record if it does not exist, but if there are no errors, it's state will otherwise be unchanged. You can call refresh() on any record to ensure it is not out of synch with your database at any time.
Finding Records
If you created the User class using the define() method you automatically have free "finder" methods:
Otherwise you can use the base find() method, which takes a hash of options, a numeric id or a complete SQL string: