title: How do you use asynchronous ORMs without huge callback chains?
body: <p>I'm using the relatively immature Joose Javascript ORM plugin (<a href="http://code.google.com/p/joose-js/wiki/JooseOnGears#Database" rel="nofollow noreferrer">project page</a>) to persist objects in an Appcelerator Titanium (<a href="http://www.appcelerator.com/products/titanium-mobile-application-development/" rel="nofollow noreferrer">company page</a>) mobile project. Since it's client side storage, the application has to check to see if the database is initialized before starting up the ORM since it inspects the DB tables to construct the classes.</p>
  <p>My problem is that this sequence of operations (and if this one is like this, other things down the road) takes a lot of callbacks to complete. I have a lot of jumping around in the code that isn't apparent to a maintainer and results in some complex call graphs and whatnot. So, I ask these questions:</p>
  <ol>
  <li>How would you asynchronously initialize a database and populate it with seed data using an ORM that needs the schema to be correct to function?</li>
  <li>Do you have any general strategies or links for async/event driven programming and keeping the call graph simple and understandable?</li>
  <li>Do you have any suggestions for Javascript ORMs/meta object systems that work with HTML 5 as a storage engine and are hopefully framework agnostic?</li>
  <li>Am I just a big newb and should be able to work this out with ease?</li>
  </ol>
  <p>Thanks folks!</p>