Skip to content

Instantly share code, notes, and snippets.

@enyo
Created December 17, 2012 14:07
Show Gist options
  • Select an option

  • Save enyo/4318530 to your computer and use it in GitHub Desktop.

Select an option

Save enyo/4318530 to your computer and use it in GitHub Desktop.
Shop.jsonProducts = [{"_id":"50145602d71fe6bdb0000003","descriptionHtml":"","descriptionSource":null,"name":"",ect....]
Shop.store.loadMany Shop.Product, Shop.jsonProducts
# The product object
Shop.Product = Shop.Model.extend
name: DS.attr "string"
tagline: DS.attr "string"
descriptionHtml: DS.attr "string"
previewImage: DS.belongsTo("Shop.Image")
images: DS.hasMany("Shop.Image")
articles: DS.hasMany("Shop.Article", embedded: yes)
Shop.Adapter = DS.Adapter.extend
find: (store, type, id) ->
throw "Trying to load a record of type '#{type}'."
findAll: (store, type) ->
throw "Trying to load records of type '#{type}'."
updateRecord: (store, type, model) ->
throw "Trying to update a record of type '#{type}'."
createRecord: (store, type, model) ->
throw "Trying to create a record of type '#{type}'."
findQuery: (store, type, query, modelArray) ->
throw "Trying to load records of type '#{type}'."
Shop.Adapter.map "Shop.Article", primaryKey: '_id'
Shop.Adapter.map "Shop.Product", primaryKey: '_id'
Shop.Adapter.map "Shop.image", primaryKey: '_id'
Shop.store = DS.Store.create
revision: 10
adapter: Shop.Adapter.create()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment