Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!doctype html>
<html>
  <head>
    <meta name="description" content="QueryFixtures" />
  </head>
<body>
  <script type="text/x-handlebars" id="application">
profiles: {{this.content}}
<ul>
{{#each content}}
<li>  hello {{this}} </li>
{{/each}}
</ul>
  </script>
  
 <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
   <script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
  <script src="http://builds.emberjs.com/ember-latest.js"></script>
  <script src="http://builds.emberjs.com/ember-data-latest.js"></script>
</body>
</html>
 
window.App = Ember.Application.create({
});
App.Store = DS.Store.extend {
  revision: 13
  adapter: DS.FixtureAdapter.extend {
    queryFixtures: (fixtures, query, type) ->
      console.log fixtures.get('length') # 2
      fixtures = fixtures.filter (item) ->
        for prop of query
          if item[prop] != query[prop]
            return false
        return true
      console.log fixtures.get('length') # 1
      return fixtures
  }
}
App.ApplicationRoute = Ember.Route.extend {
  init: ->
    profiles = App.Profile.find { isBusiness: false }
    profiles.then (data) ->
      console.log 'count: ', data.get('length') # 0 ??
  model: ->
    return App.Profile.find({isBusiness: false })
}
App.Conversation = DS.Model.extend()
App.Profile = DS.Model.extend {
  name: DS.attr('string')
  businessName: DS.attr('string')
  picture: DS.attr('string')
  isBusiness: DS.attr('boolean')
  conversations: DS.hasMany('App.Conversation')
}
App.Profile.FIXTURES = [
  {
    id: 1
    name: 'Jon Snow'
    picture: 'https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRDMu58ECeoIUUSMNPCEwWv4QAp4fT1fxXNK5AxK15I6GsAiBLC5Rl50zuOGQsDOedXbfE'
    isBusiness: false
    conversations: [101, 102]
  }
  {
    id: 2
    name: 'Jaime Lannister'
    picture: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQB_K_IfaK-da-TbwgoM1NogXSc7QPVlaxaET76D8sdMoxAd1C2WCvnsKIM8-sGFpmiPPQ'
    isBusiness: true
    businessName: 'Westeros Inc.'
    conversations: [103]
  }
]
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
mikegrassottipro
0viewers