All  That  Jazz
Upcoming SlideShare
Loading in...5
×
 

All That Jazz

on

  • 1,890 views

An intro to JazzRecord ORM for JavaScript, an agnostic library for managing databases using an ActiveRecord implementation based on Rails

An intro to JazzRecord ORM for JavaScript, an agnostic library for managing databases using an ActiveRecord implementation based on Rails

Statistics

Views

Total Views
1,890
Views on SlideShare
1,878
Embed Views
12

Actions

Likes
12
Downloads
36
Comments
0

5 Embeds 12

http://www.slideshare.net 6
http://viajesdivertidosblog.blogspot.com 2
http://musikblogoihaneymay.blogspot.com 2
http://the-english-room.wikispaces.com 1
http://itumtvblogger.blogspot.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    All  That  Jazz All That Jazz Presentation Transcript

    • All That Jazz An intro to Databases with JazzRecord ORM
    • A Little About JazzRecord
      • - Library agnostic (originally a MooTools project)  
      • - ORM inspired by ActiveRecord in Rails. Most behaviors directly portable.  
      • - Current Platforms:
        • - Gears - AIR - Titanium PR1 (and beta thanks to @jhaynie!)
    • Core Features
      • - Finders
      • - Validation
      • - Association loading
        • - Preloading - Post load
        •  
      • - Fixtures and Migrations
    • Creating Models - Basics
      • var JazzLegend = new Model({ table: "jazz_legends", columns: { name: "text", primary_instrument: "text", years_active: "text" } });
    • Creating Models - Associations
      • //new version of JazzLegend model JazzLegend = new JazzRecord.Model({ table: "jazz_legends", foreignKey: "jazz_legend_id", hasMany: {albums: "albums"}, columns: { name: "text", primary_instrument: "text", years_active: "text" } }); //associated model Album = new JazzRecord.Model({ table: "albums", belongsTo: {artist: "jazz_legends"}, columns: { title: "text", year: "text", jazz_legend_id: "number" } });
    • Finders and Record Data
      • var miles = JazzLegend.findBy("name", "Miles"); var louis = JazzLegend.first(); var dizzy = JazzLegend.find(2); miles.primary_instrument //trumpet louis.years_active //1914-1971miles.name = "Miles Dewey Davis III"; miles.save();
      •  
    • Finders and Record Data - Destroy
      • dizzy.destroy(); //someone must've grown tired of Dizzy! Album.count(); //3 albums so far, all Miles Album.destroyAll(); //like that time you lost all your CDs// when your car was broken into... Album.count(); //0, no more Miles!!
    • Validations
      • var Programmer = new JazzRecord.Model({ //... validate: { atSave: function() { this.validatesIsString("name", "You must have a name!"); this.validatesIsFloat("income", "We will gladly pay you a null salary!"); } } });
      - Callbacks run at time of create or save (or both) - Several built in validators (based on Rails') - Write your own
    • Validation Errors
      • p = Programmer.newRecord({name: 42,     income: "spare change"});p.save(); //false p.errors.name ["You must have a name!"]p.errors.income ["We will gladly pay you null salary"]p.name = "Nick"; p.income = null;p.isValid() //true
    • Association Preloading, Postloading
      • - Defaulted to 1 level deep
      • - Can be overridden at global level or per query
      • - Immediately associated records loaded automatically
      • - Additional records loaded with call to load(assocName)
      • var milesRecords = miles.albums; //all of Miles' albums milesRecords.length //3 milesRecords[0].titlemilesRecords[0].load("artist") //miles again
    • Autolinking
      • miles.albums.push(     Album.newRecord({title: "made up ish",         year: 2009     }) );miles.save();
      Any record objects pushed into a hasMany array or pushed directly onto a hasOne/belongsTo property will be auto linked on save of the base record object.
    • Auto Unlinking
      •   miles.albums.pop() //so long, fake albummiles.save();
      Any records that were previously associated/loaded which are removed become dissociated on save of base record object
    • Future of JazzRecord
      • - Unavoidable Asynchronous
      • - HTML5 Difficulties, deeply nested structures
      • - Will open up webOS, iPhone, async in AIR/Titanium
      • - Everything callback-based
      • - Initial work in 1 or 2 weeks - no association preloading
      • - No timetable for full preloading
      • - Need Contributors : coders, docs translators
    • Project:   www.jazzrecord.org groups.google.com/group/jazzrecord http://github.com/thynctank/jazzrecord/tree/master Me:   thynctank.com [email_address] thynctank (AIM/GTalk/IRC/etc)
    • JazzFusion BYOM (bring your own model)
    • Rails inspired, but dead simple
      • Provide a series of controllers, view templates and helper code in a standard file structure and sit back to watch it work.
      •  
      • Initially targeting browsers, AIR, Titanium
      • Info on writing your own routing mechanism (remote templates, server-generated dynamic content)
      • Info on writing your own view template parsers. Out of box will allow inline script tags + simple string substitution, and/or markdown
    • Some Nice Features
        • AppController's features inherited across all Controller objects
        • Automatic Hijax for forms/links, passing data to router
        • Before/after filters for keeping code DRY
    • When? Maybe June. That Burning Question