Ember-data applies model schema

I was just breaking into Ember JS for the first time and I am playing around with ember data to get JSON from the API. As far as I can tell, I need to define a JSON schema in my model if I want to access these attributes at the view / template level.

I am familiar with Backbone JS and we only needed to define relationships between models, not schema and relationships like Ember.

Is there a way to get around this, or any ember-data alternatives that don't enforce schema usage? Our data model is quite large, and defining each attribute is time consuming and somewhat unnecessary. I would rather just define the relationship between the models.

I used the following code to output this statement, so please correct me if I am wrong.

Work

app.js

App.Service = DS.Model.extend({
  title: DS.attr('string')
});

      

index.html

{{#each service in model}}
  <li>{{service.title}}</li>
{{/each}}

      

Does not work

app.js

App.Service = DS.Model.extend();

      

index.html

{{#each service in model}}
  <li>{{service.title}}</li>
{{/each}}

      

+3


source to share





All Articles