This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
dm.js /
| name | age | message | |
|---|---|---|---|
| |
ChangeLog | ||
| |
Notes.taskpaper | ||
| |
Rakefile | ||
| |
ReadMe.markdown | ||
| |
constants.yml | ||
| |
dist/ | ||
| |
etc/ | ||
| |
licenses/ | ||
| |
source/ | ||
| |
test-app.xml | ||
| |
test/ |
ReadMe.markdown
DM.js
Requires Prototype 1.6+!
This project is still in the early phases.
What Works
- HTML 5 and Google Gear back-ends
- Simple models and schema generator
- Base CRUD on models
- Event callbacks for beforeCreate, afterCreate, beforeSave, and afterSave
- Rudimentary Dataset class good for filtered reading of tables...
What Doesn't Work (Yet)
- Adobe AIR back-end
- Relationships (planned: hasMany, hasAndBelongsToMany, hasOne, belongsTo)
- Finder WHERE clauses
Example Usage
In your application's initialization, you'll need to create the database object:
// the variable name doesn't matter...
var DB = new DM.Database({
name: 'GraphicNovelist.db',
displayName: 'Graphic Novelist',
description: 'Graphic Novelist database... What?'
});
Now you can define your models:
var Script = new DM.Model('scripts', {
// This is the schema builder function you'll need to fill out...
schema: function(t){
// An id field is automatically created for models
t.text('title');
t.text('source');
t.text('html');
// Creates created_on && updated_on
t.timestamps('on');
// Not implemented yet, but this is how it'll probably work...
t.hasMany('Revision', { cascadeDelete:true });
t.beforeSave(function(self){
// use model#get and model#set to access attributes...
var renderedSource = GraphicNovelist.render( self.get('source') );
self.set('html', renderedSource );
})
}
// Any model instance methods you'd like here...
});
After you've defined/included all of your models:
DM.Model.createModels(); // Executes CREATE TABLE IF EXISTS for each model's schema...
Creating a model instance:
var script = Script.create({ title:"A new title!" });
Typical model kinds of things to do:
script.save();
script.destroy();
Script.all(function(allScripts){
// Since the HTML5 back-end is strictly asynchronous all
// database access methods require callbacks to work with
// the fetched models...
allScripts.each(function(script){
// build DOM nodes, or whatever else you'd like...
})
});
Script.find(1, function(script){
// Script 1 stuff here...
});
Todo
- Need WHERE builder so finders can actually be useful
- Tests, tests, and more tests!








