DS.Model.attributes

attributes{Ember.Map}static

Defined in addon/-private/system/model/attr.js:18

A map whose keys are the attributes of the model (properties described by DS.attr) and whose values are the meta object for the property.

Example

app/models/person.js
1
2
3
4
5
6
7
import DS from 'ember-data';
 
export default DS.Model.extend({
  firstName: attr('string'),
  lastName: attr('string'),
  birthday: attr('date')
});
1
2
3
4
5
6
7
8
9
10
11
12
13
import Ember from 'ember';
import Person from 'app/models/person';
 
var attributes = Ember.get(Person, 'attributes')
 
attributes.forEach(function(meta, name) {
  console.log(name, meta);
});
 
// prints:
// firstName {type: "string", isAttribute: true, options: Object, parentType: function, name: "firstName"}
// lastName {type: "string", isAttribute: true, options: Object, parentType: function, name: "lastName"}
// birthday {type: "date", isAttribute: true, options: Object, parentType: function, name: "birthday"}
doc_EmberJs
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.