All That Jazz

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    12 Favorites

    All That Jazz - Presentation Transcript

    1. All That Jazz An intro to Databases with JazzRecord ORM
    2. 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!)
    3. Core Features
      • - Finders
      • - Validation
      • - Association loading
        • - Preloading - Post load
        •  
      • - Fixtures and Migrations
    4. Creating Models - Basics
      • var JazzLegend = new Model({ table: "jazz_legends", columns: { name: "text", primary_instrument: "text", years_active: "text" } });
    5. 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" } });
    6. 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();
      •  
    7. 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!!
    8. 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
    9. 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
    10. 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
    11. 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.
    12. 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
    13. 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
    14. 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)
    15. JazzFusion BYOM (bring your own model)
    16. 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
    17. 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
    18. When? Maybe June. That Burning Question
    SlideShare Zeitgeist 2009

    + Nick CarterNick Carter Nominate

    custom

    1148 views, 12 favs, 5 embeds more stats

    An intro to JazzRecord ORM for JavaScript, an agnos more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1148
      • 1136 on SlideShare
      • 12 from embeds
    • Comments 0
    • Favorites 12
    • Downloads 32
    Most viewed embeds
    • 6 views on http://www.slideshare.net
    • 2 views on http://viajesdivertidosblog.blogspot.com
    • 2 views on http://musikblogoihaneymay.blogspot.com
    • 1 views on http://the-english-room.wikispaces.com
    • 1 views on http://itumtvblogger.blogspot.com

    more

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

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories