CoreObject.metaForProperty()

metaForProperty (key) privatestatic Defined in packages/ember-runtime/lib/system/core_object.js:792 In some cases, you may want to annotate computed properties with additional metadata about how they function or what values they operate on. For example, computed property functions may close over variables that are then no longer available for introspection. You can pass a hash of these values to a computed property like this: person: function() { var personId = this.get('personId'); ret

DS.BuildURLMixin#urlForFindBelongsTo()

urlForFindBelongsTo (id, modelName, snapshot) String Defined in addon/-private/adapters/build-url-mixin.js:271 Builds a URL for fetching a async belongsTo relationship when a url is not provided by the server. Example: app/adapters/application.js import DS from 'ember-data'; export default DS.JSONAPIAdapter.extend({ urlForFindBelongsTo(id, modelName, snapshot) { let baseUrl = this.buildURL(id, modelName); return `${baseUrl}/relationships`; } }); Parameters: id String mod

DS.JSONSerializer#_shouldSerializeHasMany()

_shouldSerializeHasMany (snapshot, key, relationshipType) Booleanprivate Defined in addon/serializers/json.js:878 Check if the given hasMany relationship should be serialized Parameters: snapshot DS.Snapshot key String relationshipType String Returns: Boolean true if the hasMany relationship should be serialized

DS#attr()

attr (type, options) Attribute Defined in addon/attr.js:38 DS.attr defines an attribute on a DS.Model. By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. Ember Data ships with four basic transform types: string, number, boolean and date. You can define your own transforms by subclassing DS.Transform. Note that you cannot use attr to define an attribute of id. DS.attr takes an optional hash as a second parame

Ember.computed.gt()

gt (dependentKey, value) Ember.ComputedPropertypublic Defined in packages/ember-runtime/lib/computed/computed_macros.js:287 A computed property that returns true if the provided dependent property is greater than the provided value. Example let Hamster = Ember.Object.extend({ hasTooManyBananas: Ember.computed.gt('numBananas', 10) }); let hamster = Hamster.create(); hamster.get('hasTooManyBananas'); // false hamster.set('numBananas', 3); hamster.get('hasTooManyBananas'); // false hamster

CoreObject#concatenatedProperties

concatenatedPropertiesArraypublic Defined in packages/ember-runtime/lib/system/core_object.js:255 Defines the properties that will be concatenated from the superclass (instead of overridden). By default, when you extend an Ember class a property defined in the subclass overrides a property with the same name that is defined in the superclass. However, there are some cases where it is preferable to build up a property's value by combining the superclass' property value with the subclass' val

DS.JSONAPIAdapter#coalesceFindRequests

coalesceFindRequests{boolean} Inherited from DS.RESTAdapter but overwritten in addon/adapters/json-api.js:63 By default the JSONAPIAdapter will send each find request coming from a store.find or from accessing a relationship separately to the server. If your server supports passing ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests within a single runloop. For example, if you have an initial payload of: { post: { id: 1, comments: [1, 2]

DS.Adapter#serialize()

serialize (snapshot, options) Object Defined in addon/adapter.js:255 Proxies to the serializer's serialize method. Example app/adapters/application.js import DS from 'ember-data'; export default DS.Adapter.extend({ createRecord: function(store, type, snapshot) { var data = this.serialize(snapshot, { includeId: true }); var url = `/${type.modelName}`; // ... } }); Parameters: snapshot DS.Snapshot options Object Returns: Object serialized snapshot

Creating, Updating and Deleting

Creating, Updating and Deleting Creating Records You can create records by calling the createRecord() method on the store. store.createRecord('post', { title: 'Rails is Omakase', body: 'Lorem ipsum' }); The store object is available in controllers and routes using this.get('store'). Updating Records Making changes to Ember Data records is as simple as setting the attribute you want to change: this.get('store').findRecord('person', 1).then(function(tyrion) { // ...after the record has l

DS.JSONAPIAdapter#ajaxOptions()

ajaxOptions (url, type, options) Objectprivate Inherited from DS.RESTAdapter but overwritten in addon/adapters/json-api.js:21 Parameters: url String type String The request type GET, POST, PUT, DELETE etc. options Object Returns: Object