title: Ember data localStorage Adapter: find function throws error
body: <p>I am rolling a localStorage adaper for Ember data and when I run the find function, ie:</p>
  
  <pre><code>App.store.find(App.Person, 0 );
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre><code>Uncaught Error: assertion failed: A data hash was loaded for a model of type App.Person but no primary key 'undefined' was provided. 
  </code></pre>
  
  <p>At a more general level, I am a bit confused about the relationship between 'the persistent layer' ( in this case localStorage ) and the Ember Store. What does it mean to load something to the store? Does it mean an instance of DS.Person model is created with the data ? </p>
  
  <p>Also, if you'll note I commented out a line 'App.store.didCreateRecord( model, data )' in the createRecord method since it, too is not working. What happens if I do not call store.didCreateRecord after the record has been loaded to localStorage.</p>
  
  <p>The details:</p>
  
  <pre><code>DS.LocalStorageAdapter = DS.Adapter.extend({
  
      get: Ember.get,
      set: Ember.set,
  
      createRecord: function( store, modelType, model ){
          var records, index, data;
          // get existing records of this model
          records = this.localStorage.get( modelType );
          index = records.length;
          data = this.get( model, 'data' );
          // set storageID of data
          data.set( 'storageID', index );
  
          // add data to existing records
          records[index] = data;
              // encode records
          records = JSON.stringify( records );
              // store records in localStorage
          this.localStorage.set( modelType, records );
          // App.store.didCreateRecord( model, data );
  
      },
  
  
  
      find: function( store, modelType, id ) {
          var records, model;
          records = this.localStorage.get( modelType );
          model = records[id];
          App.store.load( modelType, model );
      },
  
      localStorage: {
          set: function( modelType, value ){
              localStorage.setItem( modelType, value);
          },
  
          get: function( modelType ){
            var record = localStorage.getItem(modelType);
            record = JSON.parse(record) || [];
            return record;
          }
  
      }
  });
  
  
  
  //application model
  App.Person = DS.Model.extend({
      name: DS.attr('string', {key: 'css_name'}),
      storageID: DS.attr('number', {defaultValue: 0, key: 'storageID'}),
  
  });
  
  //create a couple of records
  App.store.createRecord(App.Person, {  ... } );
  App.store.createRecord(App.Person, {  ... } );
  
  //try and find one record
  App.store.find(App.Person, 0);
  
  error thrown:
  Uncaught Error: assertion failed: A data hash was loaded for a model of type App.Person but    no primary key 'undefined' was provided. ember-latest.js:51
  Ember.assert ember-latest.js:51
  (anonymous function) ember-latest.js:131
  DS.Store.Ember.Object.extend.load ember-data.js:1530
  DS.LocalStorageAdapter.DS.Adapter.extend.find bookApp_1.js:111
  DS.Store.Ember.Object.extend.findByClientId ember-data.js:1174
  DS.Store.Ember.Object.extend.find ember-data.js:1140
  findRecord webApplication.js:210
  onclick
  </code></pre>
  
  <p>also please note this is similar to another question posted a bit ago:
  <a href="https://stackoverflow.com/questions/10871953/ember-data-a-data-hash-was-loaded-but-no-primary-key-undefined-was-provi">Ember Data: A data hash was loaded ... but no primary key &#39;undefined&#39; was provided</a></p>
  
  <p>though the answer there seems to not really explain what is going on.</p>