diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/adapter/error-e2bd41804e.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/adapter/error-e2bd41804e.json new file mode 100644 index 000000000..bbc24f188 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/adapter/error-e2bd41804e.json @@ -0,0 +1,87 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/error", + "type": "class", + "attributes": { + "name": "@ember-data/adapter/error", + "shortname": "@ember-data/adapter/error", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter/error", + "namespace": "", + "methods": [ + { + "file": "../store/addon/-private/system/errors-utils.js", + "line": 12, + "description": "

Convert an hash of errors into an array with errors in JSON-API format.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n
import DS from 'ember-data';\n\nconst { errorsHashToArray } = DS;\n\nlet errors = {\n base: 'Invalid attributes on saving this record',\n name: 'Must be present',\n age: ['Must be present', 'Must be a number']\n};\nlet errorsArray = errorsHashToArray(errors);\n// [\n//   {\n//     title: "Invalid Document",\n//     detail: "Invalid attributes on saving this record",\n//     source: { pointer: "/data" }\n//   },\n//   {\n//     title: "Invalid Attribute",\n//     detail: "Must be present",\n//     source: { pointer: "/data/attributes/name" }\n//   },\n//   {\n//     title: "Invalid Attribute",\n//     detail: "Must be present",\n//     source: { pointer: "/data/attributes/age" }\n//   },\n//   {\n//     title: "Invalid Attribute",\n//     detail: "Must be a number",\n//     source: { pointer: "/data/attributes/age" }\n//   }\n// ]
\n
\n
\n \n", + "itemtype": "method", + "name": "errorsHashToArray", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "errors", + "description": "hash with errors as properties", + "type": "Object" + } + ], + "return": { + "description": "array of errors in JSON-API format", + "type": "Array" + }, + "class": "@ember-data/adapter/error", + "module": "@ember-data/adapter/error" + }, + { + "file": "../store/addon/-private/system/errors-utils.js", + "line": 82, + "description": "

Convert an array of errors in JSON-API format into an object.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n
import DS from 'ember-data';\n\nconst { errorsArrayToHash } = DS;\n\nlet errorsArray = [\n  {\n    title: 'Invalid Attribute',\n    detail: 'Must be present',\n    source: { pointer: '/data/attributes/name' }\n  },\n  {\n    title: 'Invalid Attribute',\n    detail: 'Must be present',\n    source: { pointer: '/data/attributes/age' }\n  },\n  {\n    title: 'Invalid Attribute',\n    detail: 'Must be a number',\n    source: { pointer: '/data/attributes/age' }\n  }\n];\n\nlet errors = errorsArrayToHash(errorsArray);\n// {\n//   "name": ["Must be present"],\n//   "age":  ["Must be present", "must be a number"]\n// }
\n
\n
\n \n", + "itemtype": "method", + "name": "errorsArrayToHash", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "errors", + "description": "array of errors in JSON-API format", + "type": "Array" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "@ember-data/adapter/error", + "module": "@ember-data/adapter/error" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/error", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/model-52da829c82.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/model-52da829c82.json new file mode 100644 index 000000000..a5edb8e96 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/model-52da829c82.json @@ -0,0 +1,125 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/model", + "type": "class", + "attributes": { + "name": "@ember-data/model", + "shortname": "@ember-data/model", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/model", + "namespace": "", + "methods": [ + { + "file": "../model/addon/-private/attr.js", + "line": 27, + "description": "

attr defines an attribute on a Model.\nBy default, attributes are passed through as-is, however you can specify an\noptional type to have the value automatically transformed.\nEmber Data ships with four basic transform types: string, number,\nboolean and date. You can define your own transforms by subclassing\nTransform.

\n

Note that you cannot use attr to define an attribute of id.

\n

attr takes an optional hash as a second parameter, currently\nsupported options are:

\n\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @attr('string') username;\n  @attr('string') email;\n  @attr('boolean', { defaultValue: false }) verified;\n}
\n
\n
\n \n

Default value can also be a function. This is useful it you want to return\na new object for each attribute.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @attr('string') username;\n  @attr('string') email;\n\n  @attr({\n    defaultValue() {\n      return {};\n    }\n  })\n  settings;\n}
\n
\n
\n \n

The options hash is passed as second argument to a transforms'\nserialize and deserialize method. This allows to configure a\ntransformation and adapt the corresponding value, based on the config:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @attr('text', {\n    uppercase: true\n  })\n  text;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/transforms/text.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Transform from '@ember-data/serializer/transform';\n\nexport default Transform.extend({\n  serialize(value, options) {\n    if (options.uppercase) {\n      return value.toUpperCase();\n    }\n\n    return value;\n  },\n\n  deserialize(value) {\n    return value;\n  }\n})
\n
\n
\n \n", + "itemtype": "method", + "name": "attr", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "type", + "description": "the attribute type", + "type": "String|Object" + }, + { + "name": "options", + "description": "a hash of options", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Attribute" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/belongs-to.js", + "line": 11, + "description": "

belongsTo is used to define One-To-One and One-To-Many\nrelationships on a Model.

\n

belongsTo takes an optional hash as a second parameter, currently\nsupported options are:

\n\n

One-To-One

\n

To declare a one-to-one relationship between two models, use\nbelongsTo:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @belongsTo('profile') profile;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/profile.js
1\n2\n3\n4\n5\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class ProfileModel extends Model {\n  @belongsTo('user') user;\n}
\n
\n
\n \n

One-To-Many

\n

To declare a one-to-many relationship between two models, use\nbelongsTo in combination with hasMany, like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany('comment') comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @belongsTo('post') post;\n}
\n
\n
\n \n

You can avoid passing a string as the first parameter. In that case Ember Data\nwill infer the type from the key name.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @belongsTo post;\n}
\n
\n
\n \n

will lookup for a Post type.

\n

Sync relationships

\n

Ember Data resolves sync relationships with the related resources\navailable in its local store, hence it is expected these resources\nto be loaded before or along-side the primary resource.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @belongsTo('post', {\n    async: false\n  })\n  post;\n}
\n
\n
\n \n

In contrast to async relationship, accessing a sync relationship\nwill always return the record (Model instance) for the existing\nlocal resource, or null. But it will error on access when\na related resource is known to exist and it has not been loaded.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
let post = comment.get('post');
\n
\n
\n \n", + "itemtype": "method", + "name": "belongsTo", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "modelName", + "description": "(optional) type of the relationship", + "type": "String" + }, + { + "name": "options", + "description": "(optional) a hash of options", + "type": "Object" + } + ], + "return": { + "description": "relationship", + "type": "Ember.computed" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/has-many.js", + "line": 10, + "description": "

hasMany is used to define One-To-Many and Many-To-Many\nrelationships on a Model.

\n

hasMany takes an optional hash as a second parameter, currently\nsupported options are:

\n\n

One-To-Many

\n

To declare a one-to-many relationship between two models, use\nbelongsTo in combination with hasMany, like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany('comment') comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @belongsTo('post') post;\n}
\n
\n
\n \n

Many-To-Many

\n

To declare a many-to-many relationship between two models, use\nhasMany:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany('tag') tags;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/tag.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class TagModel extends Model {\n  @hasMany('post') posts;\n}
\n
\n
\n \n

You can avoid passing a string as the first parameter. In that case Ember Data\nwill infer the type from the singularized key name.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany tags;\n}
\n
\n
\n \n

will lookup for a Tag type.

\n

Explicit Inverses

\n

Ember Data will do its best to discover which relationships map to\none another. In the one-to-many code above, for example, Ember Data\ncan figure out that changing the comments relationship should update\nthe post relationship on the inverse because post is the only\nrelationship to that model.

\n

However, sometimes you may have multiple belongsTo/hasMany for the\nsame type. You can specify which property on the related model is\nthe inverse using hasMany's inverse option:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @belongsTo('post') onePost;\n  @belongsTo('post') twoPost\n  @belongsTo('post') redPost;\n  @belongsTo('post') bluePost;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import Model from '@ember-data/model';\nimport { hasMany } from '@ember-decorators/data';\n\nexport default class PostModel extends Model {\n  @hasMany('comment', {\n    inverse: 'redPost'\n  })\n  comments;\n}
\n
\n
\n \n

You can also specify an inverse on a belongsTo, which works how\nyou'd expect.

\n

Sync relationships

\n

Ember Data resolves sync relationships with the related resources\navailable in its local store, hence it is expected these resources\nto be loaded before or along-side the primary resource.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany('comment', {\n    async: false\n  })\n  comments;\n}
\n
\n
\n \n

In contrast to async relationship, accessing a sync relationship\nwill always return a ManyArray instance\ncontaining the existing local resources. But it will error on access\nwhen any of the known related resources have not been loaded.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
post.get('comments').forEach((comment) => {\n\n});
\n
\n
\n \n

If you are using links with sync relationships, you have to use\nref.reload to fetch the resources.

\n", + "itemtype": "method", + "name": "hasMany", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "type", + "description": "(optional) type of the relationship", + "type": "String" + }, + { + "name": "options", + "description": "(optional) a hash of options", + "type": "Object" + } + ], + "return": { + "description": "relationship", + "type": "Ember.computed" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/model", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/store-9648856af0.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/store-9648856af0.json new file mode 100644 index 000000000..955acb87b --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-@ember-data/store-9648856af0.json @@ -0,0 +1,158 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "class", + "attributes": { + "name": "@ember-data/store", + "shortname": "@ember-data/store", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "methods": [ + { + "file": "../store/addon/-private/system/store/internal-model-factory.ts", + "line": 32, + "description": "

Retrieves the unique referentially-stable RecordIdentifier assigned to the given\nrecord instance.

\n", + "itemtype": "method", + "name": "recordIdentifierFor", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "record", + "description": "a record instance previously obstained from the store.", + "type": "Object" + } + ], + "return": { + "description": "" + }, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/normalize-model-name.ts", + "line": 10, + "description": "

This method normalizes a modelName into the format Ember Data uses\ninternally by dasherizing it.

\n", + "itemtype": "method", + "name": "normalizeModelName", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalizedModelName", + "type": "String" + }, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 111, + "description": "

Configures how unique identifier lid strings are generated by @ember-data/store.

\n

This configuration MUST occur prior to the store instance being created.

\n

Takes a method which can expect to receive various data as its first argument\nand the name of a bucket as its second argument. Currently the second\nargument will always be record data should conform to a json-api\nResource interface, but will be the normalized json data for a single\nresource that has been given to the store.

\n

The method must return a unique (to at-least the given bucket) string identifier\nfor the given data as a string to be used as the lid of an Identifier token.

\n

This method will only be called by either getOrCreateRecordIdentifier or\ncreateIdentifierForNewRecord when an identifier for the supplied data\nis not already known via lid or type + id combo and one needs to be\ngenerated or retrieved from a proprietary cache.

\n

data will be the same data argument provided to getOrCreateRecordIdentifier\nand in the createIdentifierForNewRecord case will be an object with\nonly type as a key.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import { setIdentifierGenerationMethod } form '@ember-data/store';\n\nexport function initialize(applicationInstance) {\n  // note how `count` here is now scoped to the application instance\n  // for our generation method by being inside the closure provided\n  // by the initialize function\n  let count = 0;\n\n  setIdentifierGenerationMethod((resource, bucket) => {\n    return resource.lid || `my-key-${count++}`;\n  });\n}\n\nexport default {\n  name: 'configure-ember-data-identifiers',\n  initialize\n};
\n
\n
\n \n", + "itemtype": "method", + "name": "setIdentifierGenerationMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 162, + "description": "

Configure a callback for when the identifier cache encounters new resource\ndata for an existing resource.

\n

This configuration MUST occur prior to the store instance being created.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
import { setIdentifierUpdateMethod } from '@ember-data/store';
\n
\n
\n \n

Takes a method which can expect to receive an existing Identifier alongside\nsome new data to consider as a second argument. This is an opportunity\nfor secondary lookup tables and caches associated with the identifier\nto be amended.

\n

This method is called everytime updateRecordIdentifier is called and\n with the same arguments. It provides the opportunity to update secondary\n lookup tables for existing identifiers.

\n

It will always be called after an identifier created with createIdentifierForNewRecord\n has been committed, or after an update to the record a RecordIdentifier\n is assigned to has been committed. Committed here meaning that the server\n has acknowledged the update (for instance after a call to .save())

\n

If id has not previously existed, it will be assigned to the Identifier\n prior to this UpdateMethod being called; however, calls to the parent method\n updateRecordIdentifier that attempt to change the id or calling update\n without providing an id when one is missing will throw an error.

\n", + "itemtype": "method", + "name": "setIdentifierUpdateMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 199, + "description": "

Configure a callback for when the identifier cache is going to release an identifier.

\n

This configuration MUST occur prior to the store instance being created.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
import { setIdentifierForgetMethod } from '@ember-data/store';
\n
\n
\n \n

Takes method which can expect to receive an existing Identifier that should be eliminated\nfrom any secondary lookup tables or caches that the user has populated for it.

\n", + "itemtype": "method", + "name": "setIdentifierForgetMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 219, + "description": "

Configure a callback for when the identifier cache is being torn down.

\n

This configuration MUST occur prior to the store instance being created.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
import { setIdentifierResetMethod } from '@ember-data/store';
\n
\n
\n \n

Takes a method which can expect to be called when the parent application is destroyed.

\n

If you have properly used a WeakMap to encapsulate the state of your customization\nto the application instance, you may not need to implement the resetMethod.

\n", + "itemtype": "method", + "name": "setIdentifierResetMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Adapter-17bacb1a7f.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Adapter-17bacb1a7f.json new file mode 100644 index 000000000..a35b3ad17 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Adapter-17bacb1a7f.json @@ -0,0 +1,565 @@ +{ + "data": { + "id": "ember-data-3.28.13-Adapter", + "type": "class", + "attributes": { + "name": "Adapter", + "shortname": "Adapter", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter", + "namespace": "", + "file": "../adapter/addon/index.ts", + "line": 150, + "description": "

An adapter is an object that receives requests from a store and\ntranslates them into the appropriate action to take against your\npersistence layer. The persistence layer is usually an HTTP API but\nmay be anything, such as the browser's local storage. Typically the\nadapter is not invoked directly instead its functionality is accessed\nthrough the store.

\n

Creating an Adapter

\n

Create a new subclass of Adapter in the app/adapters folder:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import Adapter from '@ember-data/adapter';\n\nexport default Adapter.extend({\n  // ...your code here\n});
\n
\n
\n \n

Model-specific adapters can be created by putting your adapter\nclass in an app/adapters/ + model-name + .js file of the application.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n
import Adapter from '@ember-data/adapter';\n\nexport default Adapter.extend({\n  // ...Post-specific adapter code goes here\n});
\n
\n
\n \n

Adapter is an abstract base class that you should override in your\napplication to customize it for your backend. The minimum set of methods\nthat you should implement is:

\n\n

To improve the network performance of your application, you can optimize\nyour adapter by overriding these lower-level methods:

\n\n

For an example of the implementation, see RESTAdapter, the\nincluded REST adapter.

\n", + "access": "public", + "tagname": "", + "extends": "EmberObject", + "methods": [ + { + "file": "../adapter/addon/index.ts", + "line": 232, + "description": "

The findRecord() method is invoked when the store is asked for a record that\nhas not previously been loaded. In response to findRecord() being called, you\nshould query your persistence layer for a record with the given ID. The findRecord\nmethod should return a promise that will resolve to a JavaScript object that will be\nnormalized by the serializer.

\n

Here is an example of the findRecord implementation:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findRecord(store, type, id, snapshot) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}/${id}`).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 275, + "description": "

The findAll() method is used to retrieve all records for a given type.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findAll(store, type) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "neverSet", + "description": "a value is never provided to this argument", + "type": "Undefined" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 314, + "description": "

This method is called when you call query on the store.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  query(store, type, query) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`, query).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "query", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "recordArray", + "description": "", + "type": "AdapterPopulatedRecordArray" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 354, + "description": "

The queryRecord() method is invoked when the store is asked for a single\nrecord through a query object.

\n

In response to queryRecord() being called, you should always fetch fresh\ndata. Once found, you can asynchronously call the store's push() method\nto push the record into the store.

\n

Here is an example queryRecord implementation:

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter, { BuildURLMixin } from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) {\n  queryRecord(store, type, query) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`, query).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "queryRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Subclass of Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 400, + "description": "

If the globally unique IDs for your records should be generated on the client,\nimplement the generateIdForRecord() method. This method will be invoked\neach time you create a new record, and the value returned from it will be\nassigned to the record's primaryKey.

\n

Most traditional REST-like HTTP APIs will not use this method. Instead, the ID\nof the record will be set by the server, and your adapter will update the store\nwith the new ID when it calls didCreateRecord(). Only implement this method if\nyou intend to generate record IDs on the client-side.

\n

The generateIdForRecord() method will be invoked with the requesting store as\nthe first parameter and the newly created record as the second parameter:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
import Adapter from '@ember-data/adapter';\nimport { v4 } from 'uuid';\n\nexport default class ApplicationAdapter extends Adapter {\n  generateIdForRecord(store, type, inputProperties) {\n    return v4();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "generateIdForRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "inputProperties", + "description": "a hash of properties to set on the\n newly created record.", + "type": "Object" + } + ], + "return": { + "description": "id", + "type": "(String|Number)" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 434, + "description": "

Proxies to the serializer's serialize method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import Adapter from '@ember-data/adapter';\n\nexport default class ApplicationAdapter extends Adapter {\n  createRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let url = `/${type.modelName}`;\n\n    // ...\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "serialized snapshot", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 462, + "description": "

Implement this method in a subclass to handle the creation of\nnew records.

\n

Serializes the record and sends it to the server.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  createRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n\n    return new RSVP.Promise(function (resolve, reject) {\n      $.ajax({\n        type: 'POST',\n        url: `/${type.modelName}`,\n        dataType: 'json',\n        data: data\n      }).then(function (data) {\n        run(null, resolve, data);\n      }, function (jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "createRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 512, + "description": "

Implement this method in a subclass to handle the updating of\na record.

\n

Serializes the record update and sends it to the server.

\n

The updateRecord method is expected to return a promise that will\nresolve with the serialized record. This allows the backend to\ninform the Ember Data store the current state of this record after\nthe update. If it is not possible to return a serialized record\nthe updateRecord promise can also resolve with undefined and the\nEmber Data store will assume all of the updates were successfully\napplied on the backend.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  updateRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let id = snapshot.id;\n\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'PUT',\n        url: `/${type.modelName}/${id}`,\n        dataType: 'json',\n        data: data\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "updateRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 571, + "description": "

Implement this method in a subclass to handle the deletion of\na record.

\n

Sends a delete request for the record to the server.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  deleteRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let id = snapshot.id;\n\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'DELETE',\n        url: `/${type.modelName}/${id}`,\n        dataType: 'json',\n        data: data\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deleteRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 644, + "description": "

The store will call findMany instead of multiple findRecord\nrequests to find multiple records at once if coalesceFindRequests\nis true.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findMany(store, type, ids, snapshots) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'GET',\n        url: `/${type.modelName}/`,\n        dataType: 'json',\n        data: { filter: { id: ids.join(',') } }\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findMany", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the records", + "type": "Model" + }, + { + "name": "ids", + "description": "", + "type": "Array" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 683, + "description": "

Organize records into groups, each of which is to be passed to separate\ncalls to findMany.

\n

For example, if your API has nested URLs that depend on the parent, you will\nwant to group records by their parent.

\n

The default implementation returns the records as a single group.

\n", + "itemtype": "method", + "name": "groupRecordsForFindMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "an array of arrays of records, each of which is to be\n loaded separately by `findMany`.", + "type": "Array" + }, + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 703, + "description": "

This method is used by the store to determine if the store should\nreload a record from the adapter when a record is requested by\nstore.findRecord.

\n

If this method returns true, the store will re-fetch a record from\nthe adapter. If this method returns false, the store will resolve\nimmediately using the cached record.

\n

For example, if you are building an events ticketing system, in which users\ncan only reserve tickets for 20 minutes at a time, and want to ensure that\nin each route you have data that is no more than 20 minutes old you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
shouldReloadRecord(store, ticketSnapshot) {\n  let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');\n  let timeDiff = moment().diff(lastAccessedAt, 'minutes');\n\n  if (timeDiff > 20) {\n    return true;\n  } else {\n    return false;\n  }\n}
\n
\n
\n \n

This method would ensure that whenever you do store.findRecord('ticket', id) you will always get a ticket that is no more than 20 minutes old. In\ncase the cached version is more than 20 minutes old, findRecord will not\nresolve until you fetched the latest version.

\n

By default this hook returns false, as most UIs should not block user\ninteractions while waiting on data update.

\n

Note that, with default settings, shouldBackgroundReloadRecord will always\nre-fetch the records in the background even if shouldReloadRecord returns\nfalse. You can override shouldBackgroundReloadRecord if this does not\nsuit your use case.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldReloadRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 754, + "description": "

This method is used by the store to determine if the store should\nreload all records from the adapter when records are requested by\nstore.findAll.

\n

If this method returns true, the store will re-fetch all records from\nthe adapter. If this method returns false, the store will resolve\nimmediately using the cached records.

\n

For example, if you are building an events ticketing system, in which users\ncan only reserve tickets for 20 minutes at a time, and want to ensure that\nin each route you have data that is no more than 20 minutes old you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
shouldReloadAll(store, snapshotArray) {\n  let snapshots = snapshotArray.snapshots();\n\n  return snapshots.any((ticketSnapshot) => {\n    let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');\n    let timeDiff = moment().diff(lastAccessedAt, 'minutes');\n\n    if (timeDiff > 20) {\n      return true;\n    } else {\n      return false;\n    }\n  });\n}
\n
\n
\n \n

This method would ensure that whenever you do store.findAll('ticket') you\nwill always get a list of tickets that are no more than 20 minutes old. In\ncase a cached version is more than 20 minutes old, findAll will not\nresolve until you fetched the latest versions.

\n

By default, this method returns true if the passed snapshotRecordArray\nis empty (meaning that there are no records locally available yet),\notherwise, it returns false.

\n

Note that, with default settings, shouldBackgroundReloadAll will always\nre-fetch all the records in the background even if shouldReloadAll returns\nfalse. You can override shouldBackgroundReloadAll if this does not suit\nyour use case.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldReloadAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 810, + "description": "

This method is used by the store to determine if the store should\nreload a record after the store.findRecord method resolves a\ncached record.

\n

This method is only checked by the store when the store is\nreturning a cached record.

\n

If this method returns true the store will re-fetch a record from\nthe adapter.

\n

For example, if you do not want to fetch complex data over a mobile\nconnection, or if the network is down, you can implement\nshouldBackgroundReloadRecord as follows:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
shouldBackgroundReloadRecord(store, snapshot) {\n  let { downlink, effectiveType } = navigator.connection;\n\n  return downlink > 0 && effectiveType === '4g';\n}
\n
\n
\n \n

By default, this hook returns true so the data for the record is updated\nin the background.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldBackgroundReloadRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 847, + "description": "

This method is used by the store to determine if the store should\nreload a record array after the store.findAll method resolves\nwith a cached record array.

\n

This method is only checked by the store when the store is\nreturning a cached record array.

\n

If this method returns true the store will re-fetch all records\nfrom the adapter.

\n

For example, if you do not want to fetch complex data over a mobile\nconnection, or if the network is down, you can implement\nshouldBackgroundReloadAll as follows:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
shouldBackgroundReloadAll(store, snapshotArray) {\n  let { downlink, effectiveType } = navigator.connection;\n\n  return downlink > 0 && effectiveType === '4g';\n}
\n
\n
\n \n

By default this method returns true, indicating that a background reload\nshould always be triggered.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldBackgroundReloadAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "Adapter", + "module": "@ember-data/adapter" + } + ], + "events": [], + "properties": [ + { + "file": "../adapter/addon/index.ts", + "line": 208, + "description": "

If you would like your adapter to use a custom serializer you can\nset the defaultSerializer property to be the name of the custom\nserializer.

\n

Note the defaultSerializer serializer has a lower priority than\na model specific serializer (i.e. PostSerializer) or the\napplication serializer.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/django.js
1\n2\n3\n4\n5\n
import Adapter from '@ember-data/adapter';\n\nexport default Adapter.extend({\n  defaultSerializer: 'django'\n});
\n
\n
\n \n", + "deprecated": true, + "itemtype": "property", + "name": "defaultSerializer", + "access": "public", + "tagname": "", + "type": "{String}", + "class": "Adapter", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 622, + "description": "

By default the store will try to coalesce all fetchRecord calls within the same runloop\ninto as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call.\nYou can opt out of this behaviour by either not implementing the findMany hook or by setting\ncoalesceFindRequests to false.

\n", + "itemtype": "property", + "name": "coalesceFindRequests", + "access": "public", + "tagname": "", + "type": "{boolean}", + "class": "Adapter", + "module": "@ember-data/adapter" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "EmberObject", + "type": "missing" + } + }, + "descendants": { + "data": [ + { + "type": "class", + "id": "ember-data-3.28.13-RESTAdapter" + } + ] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-AdapterError-c031975b42.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-AdapterError-c031975b42.json new file mode 100644 index 000000000..ba46f1347 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-AdapterError-c031975b42.json @@ -0,0 +1,79 @@ +{ + "data": { + "id": "ember-data-3.28.13-AdapterError", + "type": "class", + "attributes": { + "name": "AdapterError", + "shortname": "AdapterError", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter/error", + "namespace": "", + "file": "../adapter/addon/error.js", + "line": 7, + "description": "

A AdapterError is used by an adapter to signal that an error occurred\nduring a request to an external API. It indicates a generic error, and\nsubclasses are used to indicate specific error states. The following\nsubclasses are provided:

\n\n

To create a custom error to signal a specific error state in communicating\nwith an external API, extend the AdapterError. For example, if the\nexternal API exclusively used HTTP 503 Service Unavailable to indicate\nit was closed for maintenance:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
error.js
1\n2\n3\n
import AdapterError from '@ember-data/adapter/error';\n\nexport default AdapterError.extend({ message: "Down for maintenance." });
\n
\n
\n \n

This error would then be returned by an adapter's handleResponse method:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\nimport MaintenanceError from './maintenance-error';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  handleResponse(status) {\n    if (503 === status) {\n      return new MaintenanceError();\n    }\n\n    return this._super(...arguments);\n  }\n}
\n
\n
\n \n

And can then be detected in an application and used to send the user to an\nunder-maintenance route:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Route from '@ember/routing/route';\nimport MaintenanceError from '../adapters/maintenance-error';\n\nexport default class ApplicationRoute extends Route {\n  actions: {\n    error(error, transition) {\n      if (error instanceof MaintenanceError) {\n        this.transitionTo('under-maintenance');\n        return;\n      }\n\n      // ...other error handling logic\n    }\n  }\n}
\n
\n
\n \n

@mainName @ember-data/adapter/error\n @tag main

\n", + "_main": true, + "access": "public", + "tagname": "", + "methods": [], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [ + { + "type": "class", + "id": "ember-data-3.28.13-InvalidError" + }, + { + "type": "class", + "id": "ember-data-3.28.13-TimeoutError" + }, + { + "type": "class", + "id": "ember-data-3.28.13-AbortError" + }, + { + "type": "class", + "id": "ember-data-3.28.13-UnauthorizedError" + }, + { + "type": "class", + "id": "ember-data-3.28.13-ForbiddenError" + }, + { + "type": "class", + "id": "ember-data-3.28.13-NotFoundError" + }, + { + "type": "class", + "id": "ember-data-3.28.13-ConflictError" + }, + { + "type": "class", + "id": "ember-data-3.28.13-ServerError" + } + ] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/error", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-AdapterPopulatedRecordArray-306cc2f9c0.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-AdapterPopulatedRecordArray-306cc2f9c0.json new file mode 100644 index 000000000..085638885 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-AdapterPopulatedRecordArray-306cc2f9c0.json @@ -0,0 +1,209 @@ +{ + "data": { + "id": "ember-data-3.28.13-AdapterPopulatedRecordArray", + "type": "class", + "attributes": { + "name": "AdapterPopulatedRecordArray", + "shortname": "AdapterPopulatedRecordArray", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/record-arrays/adapter-populated-record-array.js", + "line": 15, + "description": "

Represents an ordered list of records whose order and membership is\ndetermined by the adapter. For example, a query sent to the adapter\nmay trigger a search on the server, whose results would be loaded\ninto an instance of the AdapterPopulatedRecordArray.

\n

This class should not be imported and instantiated by consuming applications.

\n
\n

If you want to update the array and get the latest records from the\nadapter, you can invoke update():

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n
// GET /users?isAdmin=true\nstore.query('user', { isAdmin: true }).then(function(admins) {\n\n  admins.then(function() {\n    console.log(admins.get("length")); // 42\n  });\n\n  // somewhere later in the app code, when new admins have been created\n  // in the meantime\n  //\n  // GET /users?isAdmin=true\n  admins.update().then(function() {\n    admins.get('isUpdating'); // false\n    console.log(admins.get("length")); // 123\n  });\n\n  admins.get('isUpdating'); // true\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "RecordArray", + "methods": [ + { + "file": "../store/addon/-private/system/record-arrays/adapter-populated-record-array.js", + "line": 104, + "itemtype": "method", + "name": "_setIdentifiers", + "params": [ + { + "name": "identifiers", + "description": "", + "type": "StableRecordIdentifier[]" + }, + { + "name": "payload", + "description": "normalized payload", + "type": "Object" + } + ], + "access": "private", + "tagname": "", + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 118, + "description": "

Retrieves an object from the content by index.

\n", + "itemtype": "method", + "name": "objectAtContent", + "access": "private", + "tagname": "", + "params": [ + { + "name": "index", + "description": "", + "type": "Number" + } + ], + "return": { + "description": "record", + "type": "Model" + }, + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 131, + "description": "

Used to get the latest version of all of the records in this array\nfrom the adapter.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
let people = store.peekAll('person');\npeople.get('isUpdating'); // false\n\npeople.update().then(function() {\n  people.get('isUpdating'); // false\n});\n\npeople.get('isUpdating'); // true
\n
\n
\n \n", + "itemtype": "method", + "name": "update", + "access": "public", + "tagname": "", + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 179, + "description": "

Saves all of the records in the RecordArray.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
let messages = store.peekAll('message');\nmessages.forEach(function(message) {\n  message.set('hasBeenSeen', true);\n});\nmessages.save();
\n
\n
\n \n", + "itemtype": "method", + "name": "save", + "access": "public", + "tagname": "", + "return": { + "description": "promise", + "type": "PromiseArray" + }, + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 230, + "itemtype": "method", + "name": "_createSnapshot", + "access": "private", + "tagname": "", + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + } + ], + "events": [], + "properties": [ + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 42, + "description": "

The array of client ids backing the record array. When a\nrecord is requested from the record array, the record\nfor the client id at the same index is materialized, if\nnecessary, by the store.

\n", + "itemtype": "property", + "name": "content", + "access": "private", + "tagname": "", + "type": "Ember.Array", + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 54, + "description": "

The flag to signal a RecordArray is finished loading data.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
let people = store.peekAll('person');\npeople.get('isLoaded'); // true
\n
\n
\n \n", + "itemtype": "property", + "name": "isLoaded", + "access": "public", + "tagname": "", + "type": "Boolean", + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 69, + "description": "

The flag to signal a RecordArray is currently loading data.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
let people = store.peekAll('person');\npeople.get('isUpdating'); // false\npeople.update();\npeople.get('isUpdating'); // true
\n
\n
\n \n", + "itemtype": "property", + "name": "isUpdating", + "access": "public", + "tagname": "", + "type": "Boolean", + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 87, + "description": "

The store that created this record array.

\n", + "itemtype": "property", + "name": "store", + "access": "private", + "tagname": "", + "type": "Store", + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 104, + "description": "

The modelClass represented by this record array.

\n", + "itemtype": "property", + "name": "type", + "access": "public", + "tagname": "", + "type": "{subclass of Model}", + "class": "AdapterPopulatedRecordArray", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "RecordArray" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-RecordArray", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BelongsToReference-c27337a2f0.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BelongsToReference-c27337a2f0.json new file mode 100644 index 000000000..56fb79ab4 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BelongsToReference-c27337a2f0.json @@ -0,0 +1,197 @@ +{ + "data": { + "id": "ember-data-3.28.13-BelongsToReference", + "type": "class", + "attributes": { + "name": "BelongsToReference", + "shortname": "BelongsToReference", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/references/belongs-to.ts", + "line": 26, + "description": "

A BelongsToReference is a low-level API that allows users and\naddon authors to perform meta-operations on a belongs-to\nrelationship.

\n", + "access": "public", + "tagname": "", + "extends": "Reference", + "methods": [ + { + "file": "../store/addon/-private/system/references/belongs-to.ts", + "line": 114, + "description": "

The id of the record that this reference refers to. Together, the\ntype() and id() methods form a composite key for the identity\nmap. This can be used to access the id of an async relationship\nwithout triggering a fetch that would normally happen if you\nattempted to use record.get('relationship.id').

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n @belongsTo({ async: true }) user;\n}\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         data: { type: 'user', id: 1 }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\n// get the identifier of the reference\nif (userRef.remoteType() === "id") {\n   let id = userRef.id();\n }
\n
\n
\n \n", + "itemtype": "method", + "name": "id", + "access": "public", + "tagname": "", + "return": { + "description": "The id of the record in this belongsTo relationship.", + "type": "String" + }, + "class": "BelongsToReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/belongs-to.ts", + "line": 172, + "description": "

push can be used to update the data in the relationship and Ember\nData will treat the new data as the canonical value of this\nrelationship on the backend.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/blog.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n   @belongsTo({ async: true }) user;\n }\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         data: { type: 'user', id: 1 }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\n// provide data for reference\nuserRef.push({\n   data: {\n     type: 'user',\n     id: 1,\n     attributes: {\n       username: "@user"\n     }\n   }\n }).then(function(user) {\n   userRef.value() === user;\n });
\n
\n
\n \n", + "itemtype": "method", + "name": "push", + "access": "public", + "tagname": "", + "params": [ + { + "name": "objectOrPromise", + "description": "a promise that resolves to a JSONAPI document object describing the new value of this relationship.", + "type": "Object|Promise" + } + ], + "return": { + "description": "A promise that resolves with the new value in this belongs-to relationship.", + "type": "Promise" + }, + "class": "BelongsToReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/belongs-to.ts", + "line": 260, + "description": "

value() synchronously returns the current value of the belongs-to\nrelationship. Unlike record.get('relationshipName'), calling\nvalue() on a reference does not trigger a fetch if the async\nrelationship is not yet loaded. If the relationship is not loaded\nit will always return null.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n  @belongsTo({ async: true }) user;\n}\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         data: { type: 'user', id: 1 }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\nuserRef.value(); // null\n\n// provide data for reference\nuserRef.push({\n   data: {\n     type: 'user',\n     id: 1,\n     attributes: {\n       username: "@user"\n     }\n   }\n }).then(function(user) {\n   userRef.value(); // user\n });
\n
\n
\n \n", + "itemtype": "method", + "name": "value", + "access": "public", + "tagname": "", + "return": { + "description": "the record in this relationship", + "type": "Model" + }, + "class": "BelongsToReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/belongs-to.ts", + "line": 322, + "description": "

Loads a record in a belongs-to relationship if it is not already\nloaded. If the relationship is already loaded this method does not\ntrigger a new load.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n  @belongsTo({ async: true }) user;\n}\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         data: { type: 'user', id: 1 }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\nuserRef.value(); // null\n\nuserRef.load().then(function(user) {\n   userRef.value() === user\n });
\n
\n
\n \n

You may also pass in an options object whose properties will be\nfed forward. This enables you to pass adapterOptions into the\nrequest given to the adapter via the reference.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
userRef.load({ adapterOptions: { isPrivate: true } }).then(function(user) {\n  userRef.value() === user;\n});
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/user.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Adapter from '@ember-data/adapter';\n\nexport default class UserAdapter extends Adapter {\n  findRecord(store, type, id, snapshot) {\n    // In the adapter you will have access to adapterOptions.\n    let adapterOptions = snapshot.adapterOptions;\n  }\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "load", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "the options to pass in.", + "type": "Object" + } + ], + "return": { + "description": "a promise that resolves with the record in this belongs-to relationship.", + "type": "Promise" + }, + "class": "BelongsToReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/belongs-to.ts", + "line": 389, + "description": "

Triggers a reload of the value in this relationship. If the\nremoteType is "link" Ember Data will use the relationship link to\nreload the relationship. Otherwise it will reload the record by its\nid.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n  @belongsTo({ async: true }) user;\n}\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         data: { type: 'user', id: 1 }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\nuserRef.reload().then(function(user) {\n   userRef.value() === user\n });
\n
\n
\n \n

You may also pass in an options object whose properties will be\nfed forward. This enables you to pass adapterOptions into the\nrequest given to the adapter via the reference. A full example\ncan be found in the load method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
userRef.reload({ adapterOptions: { isPrivate: true } })
\n
\n
\n \n", + "itemtype": "method", + "name": "reload", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "the options to pass in.", + "type": "Object" + } + ], + "return": { + "description": "a promise that resolves with the record in this belongs-to relationship after the reload has completed.", + "type": "Promise" + }, + "class": "BelongsToReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 61, + "description": "

This returns a string that represents how the reference will be\nlooked up when it is loaded. If the relationship has a link it will\nuse the "link" otherwise it defaults to "id".

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default Model.extend({\n  comments: hasMany({ async: true })\n});
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\n// get the identifier of the reference\nif (commentsRef.remoteType() === "ids") {\n  let ids = commentsRef.ids();\n} else if (commentsRef.remoteType() === "link") {\n  let link = commentsRef.link();\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "remoteType", + "access": "public", + "tagname": "", + "return": { + "description": "The name of the remote type. This should either be \"link\" or \"ids\"", + "type": "String" + }, + "class": "BelongsToReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 111, + "description": "

The link Ember Data will use to fetch or reload this belongs-to\nrelationship. By default it uses only the "related" resource linkage.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\nexport default Model.extend({\n   user: belongsTo({ async: true })\n });\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         links: {\n           related: '/articles/1/author'\n         }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\n// get the identifier of the reference\nif (userRef.remoteType() === "link") {\n   let link = userRef.link();\n }
\n
\n
\n \n", + "itemtype": "method", + "name": "link", + "access": "public", + "tagname": "", + "return": { + "description": "The link Ember Data will use to fetch or reload this belongs-to relationship.", + "type": "String" + }, + "class": "BelongsToReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 168, + "description": "

The meta data for the belongs-to relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\nexport default Model.extend({\n   user: belongsTo({ async: true })\n });\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         links: {\n           related: {\n             href: '/articles/1/author'\n           },\n           meta: {\n             lastUpdated: 1458014400000\n           }\n         }\n       }\n     }\n   }\n });\n\nlet userRef = blog.belongsTo('user');\n\nuserRef.meta() // { lastUpdated: 1458014400000 }
\n
\n
\n \n", + "itemtype": "method", + "name": "meta", + "access": "public", + "tagname": "", + "return": { + "description": "The meta information for the belongs-to relationship.", + "type": "Object" + }, + "class": "BelongsToReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Reference", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BooleanTransform-2d70931902.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BooleanTransform-2d70931902.json new file mode 100644 index 000000000..81171f362 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BooleanTransform-2d70931902.json @@ -0,0 +1,102 @@ +{ + "data": { + "id": "ember-data-3.28.13-BooleanTransform", + "type": "class", + "attributes": { + "name": "BooleanTransform", + "shortname": "BooleanTransform", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer", + "namespace": "", + "file": "../serializer/addon/-private/transforms/boolean.js", + "line": 9, + "description": "

The BooleanTransform class is used to serialize and deserialize\nboolean attributes on Ember Data record objects. This transform is\nused when boolean is passed as the type parameter to the\nattr function.

\n

Usage

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @attr('boolean') isAdmin;\n  @attr('string') name;\n  @attr('string') email;\n}
\n
\n
\n \n

By default, the boolean transform only allows for values of true or\nfalse. You can opt into allowing null values for\nboolean attributes via attr('boolean', { allowNull: true })

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @attr('string') email;\n  @attr('string') username;\n  @attr('boolean', { allowNull: true }) wantsWeeklyEmail;\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "Transform", + "methods": [ + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 80, + "description": "

When given a deserialized value from a record attribute this\nmethod must return the serialized value.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
import { isEmpty } from '@ember/utils';\n\nserialize(deserialized, options) {\n  return isEmpty(deserialized) ? null : Number(deserialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "deserialized", + "description": "The deserialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The serialized value" + }, + "class": "BooleanTransform", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Transform" + }, + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 102, + "description": "

When given a serialized value from a JSON object this method must\nreturn the deserialized value for the record attribute.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
deserialize(serialized, options) {\n  return empty(serialized) ? null : Number(serialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deserialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "serialized", + "description": "The serialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The deserialized value" + }, + "class": "BooleanTransform", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Transform" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Transform", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BuildURLMixin-29a90f7ddd.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BuildURLMixin-29a90f7ddd.json new file mode 100644 index 000000000..9c262e2e1 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-BuildURLMixin-29a90f7ddd.json @@ -0,0 +1,464 @@ +{ + "data": { + "id": "ember-data-3.28.13-BuildURLMixin", + "type": "class", + "attributes": { + "name": "BuildURLMixin", + "shortname": "BuildURLMixin", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [ + "RESTAdapter" + ], + "module": "@ember-data/adapter", + "namespace": "", + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 15, + "description": "

Using BuildURLMixin

\n

To use URL building, include the mixin when extending an adapter, and call buildURL where needed.\nThe default behaviour is designed for RESTAdapter.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
import Adapter, { BuildURLMixin } from '@ember-data/adapter';\n\nexport default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) {\n  findRecord(store, type, id, snapshot) {\n    var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');\n    return this.ajax(url, 'GET');\n  }\n}
\n
\n
\n \n

Attributes

\n

The host and namespace attributes will be used if defined, and are optional.

\n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 42, + "description": "

Builds a URL for a given type and optional ID.

\n

By default, it pluralizes the type's name (for example, 'post'\nbecomes 'posts' and 'person' becomes 'people'). To override the\npluralization see pathForType.

\n

If an ID is specified, it adds the ID to the path generated\nfor the type, separated by a /.

\n

When called by RESTAdapter.findMany() the id and snapshot parameters\nwill be arrays of ids and snapshots.

\n", + "itemtype": "method", + "name": "buildURL", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "single id or array of ids or query", + "type": "(String|Array|Object)" + }, + { + "name": "snapshot", + "description": "single snapshot or array of snapshots", + "type": "(Snapshot|SnapshotRecordArray)" + }, + { + "name": "requestType", + "description": "", + "type": "String" + }, + { + "name": "query", + "description": "object of query parameters to send for query requests.", + "type": "Object" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 97, + "itemtype": "method", + "name": "_buildURL", + "access": "private", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 132, + "description": "

Builds a URL for a store.findRecord(type, id) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/user.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindRecord(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id, snapshot);\n    return `${baseUrl}/users/${snapshot.adapterOptions.user_id}/playlists/${id}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 160, + "description": "

Builds a URL for a store.findAll(type) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindAll(modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName);\n    return `${baseUrl}/data/comments.json`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 186, + "description": "

Builds a URL for a store.query(type, query) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  host = 'https://api.github.com';\n  urlForQuery (query, modelName) {\n    switch(modelName) {\n      case 'repo':\n        return `https://api.github.com/orgs/${query.orgId}/repos`;\n      default:\n        return super.urlForQuery(...arguments);\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForQuery", + "access": "public", + "tagname": "", + "params": [ + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 217, + "description": "

Builds a URL for a store.queryRecord(type, query) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForQueryRecord({ slug }, modelName) {\n    let baseUrl = this.buildURL();\n    return `${baseUrl}/${encodeURIComponent(slug)}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForQueryRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 243, + "description": "

Builds a URL for coalescing multiple store.findRecord(type, id)\nrecords into 1 request when the adapter's coalesceFindRequests\nproperty is true.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForFindMany(ids, modelName) {\n    let baseUrl = this.buildURL();\n    return `${baseUrl}/coalesce`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "ids", + "description": "", + "type": "Array" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 272, + "description": "

Builds a URL for fetching an async hasMany relationship when a URL\nis not provided by the server.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindHasMany(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id);\n    return `${baseUrl}/relationships`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 300, + "description": "

Builds a URL for fetching an async belongsTo relationship when a url\nis not provided by the server.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindBelongsTo(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id);\n    return `${baseUrl}/relationships`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 328, + "description": "

Builds a URL for a record.save() call when the record was created\nlocally using store.createRecord().

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForCreateRecord(modelName, snapshot) {\n    return super.urlForCreateRecord(...arguments) + '/new';\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForCreateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 354, + "description": "

Builds a URL for a record.save() call when the record has been updated locally.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForUpdateRecord(id, modelName, snapshot) {\n    return `/${id}/feed?access_token=${snapshot.adapterOptions.token}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForUpdateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 380, + "description": "

Builds a URL for a record.save() call when the record has been deleted locally.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForDeleteRecord(id, modelName, snapshot) {\n    return super.urlForDeleteRecord(...arguments) + '/destroy';\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForDeleteRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 406, + "itemtype": "method", + "name": "urlPrefix", + "access": "private", + "tagname": "", + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "parentURL", + "description": "", + "type": "String" + } + ], + "return": { + "description": "urlPrefix", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 447, + "description": "

Determines the pathname for a given type.

\n

By default, it pluralizes the type's name (for example,\n'post' becomes 'posts' and 'person' becomes 'people').

\n

Pathname customization

\n

For example, if you have an object LineItem with an\nendpoint of /line_items/.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { decamelize } from '@ember/string';\nimport { pluralize } from 'ember-inflector';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  pathForType(modelName) {\n    var decamelized = decamelize(modelName);\n    return pluralize(decamelized);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "pathForType", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "path", + "type": "String" + }, + "class": "BuildURLMixin", + "module": "@ember-data/adapter" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-DateTransform-fc695f3da6.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-DateTransform-fc695f3da6.json new file mode 100644 index 000000000..8a87e9ddd --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-DateTransform-fc695f3da6.json @@ -0,0 +1,102 @@ +{ + "data": { + "id": "ember-data-3.28.13-DateTransform", + "type": "class", + "attributes": { + "name": "DateTransform", + "shortname": "DateTransform", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer", + "namespace": "", + "file": "../serializer/addon/-private/transforms/date.js", + "line": 7, + "description": "

The DateTransform class is used to serialize and deserialize\ndate attributes on Ember Data record objects. This transform is used\nwhen date is passed as the type parameter to the\nattr function. It uses the ISO 8601\nstandard.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/score.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class ScoreModel extends Model {\n   @attr('number') value;\n   @belongsTo('player') player;\n   @attr('date') date;\n }
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "Transform", + "methods": [ + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 80, + "description": "

When given a deserialized value from a record attribute this\nmethod must return the serialized value.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
import { isEmpty } from '@ember/utils';\n\nserialize(deserialized, options) {\n  return isEmpty(deserialized) ? null : Number(deserialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "deserialized", + "description": "The deserialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The serialized value" + }, + "class": "DateTransform", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Transform" + }, + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 102, + "description": "

When given a serialized value from a JSON object this method must\nreturn the deserialized value for the record attribute.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
deserialize(serialized, options) {\n  return empty(serialized) ? null : Number(serialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deserialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "serialized", + "description": "The serialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The deserialized value" + }, + "class": "DateTransform", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Transform" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Transform", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-EmbeddedRecordsMixin-0ab259b966.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-EmbeddedRecordsMixin-0ab259b966.json new file mode 100644 index 000000000..99a34a327 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-EmbeddedRecordsMixin-0ab259b966.json @@ -0,0 +1,207 @@ +{ + "data": { + "id": "ember-data-3.28.13-EmbeddedRecordsMixin", + "type": "class", + "attributes": { + "name": "EmbeddedRecordsMixin", + "shortname": "EmbeddedRecordsMixin", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer/rest", + "namespace": "", + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 12, + "description": "

Using Embedded Records

\n

EmbeddedRecordsMixin supports serializing embedded records.

\n

To set up embedded records, include the mixin when extending a serializer,\nthen define and configure embedded (model) relationships.

\n

Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.

\n

Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources.

\n

Below is an example of a per-type serializer (post type).

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\nexport default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n  attrs = {\n    author: { embedded: 'always' },\n    comments: { serialize: 'ids' }\n  }\n}
\n
\n
\n \n

Note that this use of { embedded: 'always' } is unrelated to\nthe { embedded: 'always' } that is defined as an option on attr as part of\ndefining a model while working with the ActiveModelSerializer. Nevertheless,\nusing { embedded: 'always' } as an option to attr is not a valid way to set up\nembedded records.

\n

The attrs option for a resource { embedded: 'always' } is shorthand for:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
{\n  serialize: 'records',\n  deserialize: 'records'\n}
\n
\n
\n \n

Configuring Attrs

\n

A resource's attrs option may be set to use ids, records or false for the\nserialize and deserialize settings.

\n

The attrs property can be set on the ApplicationSerializer or a per-type\nserializer.

\n

In the case where embedded JSON is expected while extracting a payload (reading)\nthe setting is deserialize: 'records', there is no need to use ids when\nextracting as that is the default behaviour without this mixin if you are using\nthe vanilla EmbeddedRecordsMixin. Likewise, to embed JSON in the payload while\nserializing serialize: 'records' is the setting to use. There is an option of\nnot embedding JSON in the serialized payload by using serialize: 'ids'. If you\ndo not want the relationship sent at all, you can use serialize: false.

\n

EmbeddedRecordsMixin defaults

\n

If you do not overwrite attrs for a specific relationship, the EmbeddedRecordsMixin\nwill behave in the following way:

\n

BelongsTo: { serialize: 'id', deserialize: 'id' }\nHasMany: { serialize: false, deserialize: 'ids' }

\n

Model Relationships

\n

Embedded records must have a model defined to be extracted and serialized. Note that\nwhen defining any relationships on your model such as belongsTo and hasMany, you\nshould not both specify async: true and also indicate through the serializer's\nattrs attribute that the related model should be embedded for deserialization.\nIf a model is declared embedded for deserialization (embedded: 'always' or deserialize: 'records'),\nthen do not use async: true.

\n

To successfully extract and serialize embedded records the model relationships\nmust be set up correctly. See the\ndefining relationships\nsection of the Defining Models guide page.

\n

Records without an id property are not considered embedded records, model\ninstances must have an id property to be used with Ember Data.

\n

Example JSON payloads, Models and Serializers

\n

When customizing a serializer it is important to grok what the customizations\nare. Please read the docs for the methods this mixin provides, in case you need\nto modify it to fit your specific needs.

\n

For example, review the docs for each method of this mixin:

\n\n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 107, + "description": "

Normalize the record and recursively normalize/extract all the embedded records\nwhile pushing them into the store as they are encountered

\n

A payload with an attr configured for embedded records needs to be extracted:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
{\n  "post": {\n    "id": "1"\n    "title": "Rails is omakase",\n    "comments": [{\n      "id": "1",\n      "body": "Rails is unagi"\n    }, {\n      "id": "2",\n      "body": "Omakase O_o"\n    }]\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "hash", + "description": "to be normalized", + "type": "Object" + }, + { + "name": "prop", + "description": "the hash has been referenced by", + "type": "String" + } + ], + "return": { + "description": "the normalized hash", + "type": "Object" + }, + "class": "EmbeddedRecordsMixin", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 151, + "description": "

Serialize belongsTo relationship when it is configured as an embedded object.

\n

This example of an author model belongs to a post model:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nPost = Model.extend({\n  title:    attr('string'),\n  body:     attr('string'),\n  author:   belongsTo('author')\n});\n\nAuthor = Model.extend({\n  name:     attr('string'),\n  post:     belongsTo('post')\n});
\n
\n
\n \n

Use a custom (type) serializer for the post model to configure embedded author

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\nexport default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n  attrs = {\n    author: { embedded: 'always' }\n  }\n}
\n
\n
\n \n

A payload with an attribute configured for embedded records can serialize\nthe records together under the root attribute's payload:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
{\n  "post": {\n    "id": "1"\n    "title": "Rails is omakase",\n    "author": {\n      "id": "2"\n      "name": "dhh"\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "EmbeddedRecordsMixin", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 253, + "description": "

Serializes hasMany relationships when it is configured as embedded objects.

\n

This example of a post model has many comments:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';\n\nPost = Model.extend({\n  title:    attr('string'),\n  body:     attr('string'),\n  comments: hasMany('comment')\n});\n\nComment = Model.extend({\n  body:     attr('string'),\n  post:     belongsTo('post')\n});
\n
\n
\n \n

Use a custom (type) serializer for the post model to configure embedded comments

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\nexport default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n  attrs = {\n    comments: { embedded: 'always' }\n  }\n}
\n
\n
\n \n

A payload with an attribute configured for embedded records can serialize\nthe records together under the root attribute's payload:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
{\n  "post": {\n    "id": "1"\n    "title": "Rails is omakase",\n    "body": "I want this for my ORM, I want that for my template language..."\n    "comments": [{\n      "id": "1",\n      "body": "Rails is unagi"\n    }, {\n      "id": "2",\n      "body": "Omakase O_o"\n    }]\n  }\n}
\n
\n
\n \n

The attrs options object can use more specific instruction for extracting and\nserializing. When serializing, an option to embed ids, ids-and-types or records can be set.\nWhen extracting the only option is records.

\n

So { embedded: 'always' } is shorthand for:\n{ serialize: 'records', deserialize: 'records' }

\n

To embed the ids for a related object (using a hasMany relationship):

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\nexport default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n  attrs = {\n    comments: { serialize: 'ids', deserialize: 'records' }\n  }\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
{\n  "post": {\n    "id": "1"\n    "title": "Rails is omakase",\n    "body": "I want this for my ORM, I want that for my template language..."\n    "comments": ["1", "2"]\n  }\n}
\n
\n
\n \n

To embed the relationship as a collection of objects with id and type keys, set\nids-and-types for the related object.

\n

This is particularly useful for polymorphic relationships where records don't share\nthe same table and the id is not enough information.

\n

For example having a user that has many pets:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n
User = Model.extend({\n  name: attr('string'),\n  pets: hasMany('pet', { polymorphic: true })\n});\n\nPet = Model.extend({\n  name: attr('string'),\n});\n\nCat = Pet.extend({\n  // ...\n});\n\nParrot = Pet.extend({\n  // ...\n});
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/user.js
1\n2\n3\n4\n5\n6\n7\n
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\nexport default class UserSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n  attrs = {\n    pets: { serialize: 'ids-and-types', deserialize: 'records' }\n  }\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
{\n  "user": {\n    "id": "1"\n    "name": "Bertin Osborne",\n    "pets": [\n      { "id": "1", "type": "Cat" },\n      { "id": "1", "type": "Parrot"}\n    ]\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "EmbeddedRecordsMixin", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 468, + "description": "

When serializing an embedded record, modify the property (in the JSON payload)\nthat refers to the parent record (foreign key for the relationship).

\n

Serializing a belongsTo relationship removes the property that refers to the\nparent record

\n

Serializing a hasMany relationship does not remove the property that refers to\nthe parent record.

\n", + "itemtype": "method", + "name": "removeEmbeddedForeignKey", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "embeddedSnapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + }, + { + "name": "json", + "description": "", + "type": "Object" + } + ], + "class": "EmbeddedRecordsMixin", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 546, + "itemtype": "method", + "name": "_extractEmbeddedRecords", + "access": "private", + "tagname": "", + "class": "EmbeddedRecordsMixin", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 564, + "itemtype": "method", + "name": "_extractEmbeddedHasMany", + "access": "private", + "tagname": "", + "class": "EmbeddedRecordsMixin", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 593, + "itemtype": "method", + "name": "_extractEmbeddedBelongsTo", + "access": "private", + "tagname": "", + "class": "EmbeddedRecordsMixin", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/-private/embedded-records-mixin.js", + "line": 616, + "itemtype": "method", + "name": "_normalizeEmbeddedRelationship", + "access": "private", + "tagname": "", + "class": "EmbeddedRecordsMixin", + "module": "@ember-data/serializer/rest" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer/rest", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Errors-9bc753c95a.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Errors-9bc753c95a.json new file mode 100644 index 000000000..ded6a378c --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Errors-9bc753c95a.json @@ -0,0 +1,274 @@ +{ + "data": { + "id": "ember-data-3.28.13-Errors", + "type": "class", + "attributes": { + "name": "Errors", + "shortname": "Errors", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../model/addon/-private/errors.js", + "line": 14, + "description": "

Holds validation errors for a given record, organized by attribute names.

\n

This class is not directly instantiable.

\n

Every Model has an errors property that is an instance of\nErrors. This can be used to display validation error\nmessages returned from the server when a record.save() rejects.

\n

For Example, if you had a User model that looked like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n6\n
import Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @attr('string') username;\n  @attr('string') email;\n}
\n
\n
\n \n

And you attempted to save a record that did not validate on the backend:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
let user = store.createRecord('user', {\n  username: 'tomster',\n  email: 'invalidEmail'\n});\nuser.save();
\n
\n
\n \n

Your backend would be expected to return an error response that described\nthe problem, so that error messages can be generated on the app.

\n

API responses will be translated into instances of Errors differently,\ndepending on the specific combination of adapter and serializer used. You\nmay want to check the documentation or the source code of the libraries\nthat you are using, to know how they expect errors to be communicated.

\n

Errors can be displayed to the user by accessing their property name\nto get an array of all the error objects for that property. Each\nerror object is a JavaScript object with two keys:

\n\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
<label>Username: <Input @value={{@model.username}} /> </label>\n{{#each @model.errors.username as |error|}}\n  <div class="error">\n    {{error.message}}\n  </div>\n{{/each}}\n\n<label>Email: <Input @value={{@model.email}} /> </label>\n{{#each @model.errors.email as |error|}}\n  <div class="error">\n    {{error.message}}\n  </div>\n{{/each}}
\n
\n
\n \n

You can also access the special messages property on the error\nobject to get an array of all the error strings.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{{#each @model.errors.messages as |message|}}\n  <div class="error">\n    {{message}}\n  </div>\n{{/each}}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "Ember.ArrayProxy", + "uses": [ + "Ember.Evented" + ], + "methods": [ + { + "file": "../model/addon/-private/errors.js", + "line": 91, + "description": "

Register with target handler

\n", + "itemtype": "method", + "name": "_registerHandlers", + "access": "private", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 113, + "description": "

Returns errors for a given attribute

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
let user = store.createRecord('user', {\n  username: 'tomster',\n  email: 'invalidEmail'\n});\nuser.save().catch(function(){\n  user.get('errors').errorsFor('email'); // returns:\n  // [{attribute: "email", message: "Doesn't look like a valid email."}]\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "errorsFor", + "access": "public", + "tagname": "", + "params": [ + { + "name": "attribute", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "Array" + }, + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 178, + "itemtype": "method", + "name": "unknownProperty", + "access": "private", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 209, + "description": "

Manually adds errors to the record. This will trigger the becameInvalid event/ lifecycle method on\n the record and transition the record into an invalid state.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
 let errors = get(user, 'errors');\n\n // add multiple errors\n errors.add('password', [\n   'Must be at least 12 characters',\n   'Must contain at least one symbol',\n   'Cannot contain your name'\n ]);\n\n errors.errorsFor('password');\n // =>\n // [\n //   { attribute: 'password', message: 'Must be at least 12 characters' },\n //   { attribute: 'password', message: 'Must contain at least one symbol' },\n //   { attribute: 'password', message: 'Cannot contain your name' },\n // ]\n\n // add a single error\n errors.add('username', 'This field is required');\n\n errors.errorsFor('username');\n // =>\n // [\n //   { attribute: 'username', message: 'This field is required' },\n // ]
\n
\n
\n \n", + "itemtype": "method", + "name": "add", + "access": "public", + "tagname": "", + "params": [ + { + "name": "attribute", + "description": "- the property name of an attribute or relationship", + "type": "String" + }, + { + "name": "messages", + "description": "- an error message or array of error messages for the attribute", + "type": "String[]|string" + } + ], + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 261, + "description": "

Adds error messages to a given attribute without sending event.

\n", + "itemtype": "method", + "name": "_add", + "access": "private", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 276, + "itemtype": "method", + "name": "_findOrCreateMessages", + "access": "private", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 301, + "description": "

Manually removes all errors for a given member from the record.\n This will transition the record into a valid state, and\n triggers the becameValid event and lifecycle method.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
 let errors = get('user', errors);\n errors.add('phone', ['error-1', 'error-2']);\n\n errors.errorsFor('phone');\n // =>\n // [\n //   { attribute: 'phone', message: 'error-1' },\n //   { attribute: 'phone', message: 'error-2' },\n // ]\n\n errors.remove('phone');\n\n errors.errorsFor('phone');\n // => undefined
\n
\n
\n \n", + "itemtype": "method", + "name": "remove", + "access": "public", + "tagname": "", + "params": [ + { + "name": "member", + "description": "- the property name of an attribute or relationship", + "type": "String" + } + ], + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 345, + "description": "

Removes all error messages from the given attribute without sending event.

\n", + "itemtype": "method", + "name": "_remove", + "access": "private", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 374, + "description": "

Manually clears all errors for the record.\n This will transition the record into a valid state, and\n will trigger the becameValid event and lifecycle method.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n
let errors = get('user', errors);\nerrors.add('username', ['error-a']);\nerrors.add('phone', ['error-1', 'error-2']);\n\nerrors.errorsFor('username');\n// =>\n// [\n//   { attribute: 'username', message: 'error-a' },\n// ]\n\nerrors.errorsFor('phone');\n// =>\n// [\n//   { attribute: 'phone', message: 'error-1' },\n//   { attribute: 'phone', message: 'error-2' },\n// ]\n\nerrors.clear();\n\nerrors.errorsFor('username');\n// => undefined\n\nerrors.errorsFor('phone');\n// => undefined\n\nerrors.get('messages')\n// => []
\n
\n
\n \n", + "itemtype": "method", + "name": "clear", + "access": "public", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 427, + "description": "

Removes all error messages.\nto the record.

\n", + "itemtype": "method", + "name": "_clear", + "access": "private", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 454, + "description": "

Checks if there are error messages for the given attribute.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/controllers/user/edit.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import Controller from '@ember/controller';\nimport { action } from '@ember/object';\n\nexport default class UserEditController extends Controller {\n  @action\n  save(user) {\n    if (user.get('errors').has('email')) {\n      return alert('Please update your email before attempting to save.');\n    }\n    user.save();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "has", + "access": "public", + "tagname": "", + "params": [ + { + "name": "attribute", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if there some errors on given attribute", + "type": "Boolean" + }, + "class": "Errors", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [ + { + "file": "../model/addon/-private/errors.js", + "line": 104, + "itemtype": "property", + "name": "errorsByAttributeName", + "type": "{MapWithDefault}", + "access": "private", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 151, + "description": "

An array containing all of the error messages for this\nrecord. This is useful for displaying all errors to the user.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{{#each @model.errors.messages as |message|}}\n  <div class="error">\n    {{message}}\n  </div>\n{{/each}}
\n
\n
\n \n", + "itemtype": "property", + "name": "messages", + "access": "public", + "tagname": "", + "type": "{Array}", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 169, + "itemtype": "property", + "name": "content", + "type": "{Array}", + "access": "private", + "tagname": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 190, + "description": "

Total number of errors.

\n", + "itemtype": "property", + "name": "length", + "type": "{Number}", + "access": "public", + "tagname": "", + "readonly": "", + "class": "Errors", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/errors.js", + "line": 199, + "description": "

true if we have no errors.

\n", + "itemtype": "property", + "name": "isEmpty", + "type": "{Boolean}", + "access": "public", + "tagname": "", + "readonly": "", + "class": "Errors", + "module": "@ember-data/store" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "Ember.ArrayProxy", + "type": "missing" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-HasManyReference-187134d9f4.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-HasManyReference-187134d9f4.json new file mode 100644 index 000000000..96436c336 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-HasManyReference-187134d9f4.json @@ -0,0 +1,212 @@ +{ + "data": { + "id": "ember-data-3.28.13-HasManyReference", + "type": "class", + "attributes": { + "name": "HasManyReference", + "shortname": "HasManyReference", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/references/has-many.ts", + "line": 28, + "description": "

A HasManyReference is a low-level API that allows users and addon\nauthors to perform meta-operations on a has-many relationship.

\n", + "access": "public", + "tagname": "", + "extends": "Reference", + "methods": [ + { + "file": "../store/addon/-private/system/references/has-many.ts", + "line": 137, + "description": "

This returns a string that represents how the reference will be\nlooked up when it is loaded. If the relationship has a link it will\nuse the "link" otherwise it defaults to "id".

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany({ async: true }) comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\n// get the identifier of the reference\nif (commentsRef.remoteType() === "ids") {\n  let ids = commentsRef.ids();\n} else if (commentsRef.remoteType() === "link") {\n  let link = commentsRef.link();\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "remoteType", + "access": "public", + "tagname": "", + "return": { + "description": "The name of the remote type. This should either be `link` or `ids`", + "type": "String" + }, + "class": "HasManyReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/has-many.ts", + "line": 188, + "description": "

ids() returns an array of the record IDs in this relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany({ async: true }) comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\ncommentsRef.ids(); // ['1']
\n
\n
\n \n", + "itemtype": "method", + "name": "ids", + "access": "public", + "tagname": "", + "return": { + "description": "The ids in this has-many relationship", + "type": "Array" + }, + "class": "HasManyReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/has-many.ts", + "line": 241, + "description": "

push can be used to update the data in the relationship and Ember\nData will treat the new data as the canonical value of this\nrelationship on the backend.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany({ async: true }) comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\ncommentsRef.ids(); // ['1']\n\ncommentsRef.push([\n[{ type: 'comment', id: 2 }],\n[{ type: 'comment', id: 3 }],\n])\n\ncommentsRef.ids(); // ['2', '3']
\n
\n
\n \n", + "itemtype": "method", + "name": "push", + "access": "public", + "tagname": "", + "params": [ + { + "name": "objectOrPromise", + "description": "a promise that resolves to a JSONAPI document object describing the new value of this relationship.", + "type": "Array|Promise" + } + ], + "return": { + "description": "", + "type": "ManyArray" + }, + "class": "HasManyReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/has-many.ts", + "line": 347, + "description": "

value() synchronously returns the current value of the has-many\nrelationship. Unlike record.get('relationshipName'), calling\nvalue() on a reference does not trigger a fetch if the async\nrelationship is not yet loaded. If the relationship is not loaded\nit will always return null.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany({ async: true }) comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\npost.get('comments').then(function(comments) {\n  commentsRef.value() === comments\n})
\n
\n
\n \n", + "itemtype": "method", + "name": "value", + "access": "public", + "tagname": "", + "return": { + "description": "", + "type": "ManyArray" + }, + "class": "HasManyReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/has-many.ts", + "line": 397, + "description": "

Loads the relationship if it is not already loaded. If the\nrelationship is already loaded this method does not trigger a new\nload. This causes a request to the specified\nrelationship link or reloads all items currently in the relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany({ async: true }) comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\ncommentsRef.load().then(function(comments) {\n  //...\n});
\n
\n
\n \n

You may also pass in an options object whose properties will be\nfed forward. This enables you to pass adapterOptions into the\nrequest given to the adapter via the reference.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
commentsRef.load({ adapterOptions: { isPrivate: true } })\n  .then(function(comments) {\n    //...\n  });
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/comment.js
1\n2\n3\n4\n5\n6\n
export default ApplicationAdapter.extend({\n  findMany(store, type, id, snapshots) {\n    // In the adapter you will have access to adapterOptions.\n    let adapterOptions = snapshots[0].adapterOptions;\n  }\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "load", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "the options to pass in.", + "type": "Object" + } + ], + "return": { + "description": "a promise that resolves with the ManyArray in\nthis has-many relationship.", + "type": "Promise" + }, + "class": "HasManyReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/has-many.ts", + "line": 466, + "description": "

Reloads this has-many relationship. This causes a request to the specified\nrelationship link or reloads all items currently in the relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany({ async: true }) comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\ncommentsRef.reload().then(function(comments) {\n  //...\n});
\n
\n
\n \n

You may also pass in an options object whose properties will be\nfed forward. This enables you to pass adapterOptions into the\nrequest given to the adapter via the reference. A full example\ncan be found in the load method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
commentsRef.reload({ adapterOptions: { isPrivate: true } })
\n
\n
\n \n", + "itemtype": "method", + "name": "reload", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "the options to pass in.", + "type": "Object" + } + ], + "return": { + "description": "a promise that resolves with the ManyArray in this has-many relationship.", + "type": "Promise" + }, + "class": "HasManyReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 61, + "description": "

This returns a string that represents how the reference will be\nlooked up when it is loaded. If the relationship has a link it will\nuse the "link" otherwise it defaults to "id".

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default Model.extend({\n  comments: hasMany({ async: true })\n});
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\n// get the identifier of the reference\nif (commentsRef.remoteType() === "ids") {\n  let ids = commentsRef.ids();\n} else if (commentsRef.remoteType() === "link") {\n  let link = commentsRef.link();\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "remoteType", + "access": "public", + "tagname": "", + "return": { + "description": "The name of the remote type. This should either be \"link\" or \"ids\"", + "type": "String" + }, + "class": "HasManyReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 111, + "description": "

The link Ember Data will use to fetch or reload this belongs-to\nrelationship. By default it uses only the "related" resource linkage.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\nexport default Model.extend({\n   user: belongsTo({ async: true })\n });\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         links: {\n           related: '/articles/1/author'\n         }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\n// get the identifier of the reference\nif (userRef.remoteType() === "link") {\n   let link = userRef.link();\n }
\n
\n
\n \n", + "itemtype": "method", + "name": "link", + "access": "public", + "tagname": "", + "return": { + "description": "The link Ember Data will use to fetch or reload this belongs-to relationship.", + "type": "String" + }, + "class": "HasManyReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 168, + "description": "

The meta data for the belongs-to relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\nexport default Model.extend({\n   user: belongsTo({ async: true })\n });\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         links: {\n           related: {\n             href: '/articles/1/author'\n           },\n           meta: {\n             lastUpdated: 1458014400000\n           }\n         }\n       }\n     }\n   }\n });\n\nlet userRef = blog.belongsTo('user');\n\nuserRef.meta() // { lastUpdated: 1458014400000 }
\n
\n
\n \n", + "itemtype": "method", + "name": "meta", + "access": "public", + "tagname": "", + "return": { + "description": "The meta information for the belongs-to relationship.", + "type": "Object" + }, + "class": "HasManyReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Reference", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-IdentifierCache-319a57680a.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-IdentifierCache-319a57680a.json new file mode 100644 index 000000000..4197e1ba8 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-IdentifierCache-319a57680a.json @@ -0,0 +1,182 @@ +{ + "data": { + "id": "ember-data-3.28.13-IdentifierCache", + "type": "class", + "attributes": { + "name": "IdentifierCache", + "shortname": "IdentifierCache", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 102, + "description": "

Each instance of {Store} receives a unique instance of a IdentifierCache.

\n

This cache is responsible for assigning or retrieving the unique identify\nfor arbitrary resource data encountered by the store. Data representing\na unique resource or record should always be represented by the same\nidentifier.

\n

It can be configured by consuming applications.

\n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 140, + "description": "

Internal hook to allow management of merge conflicts with identifiers.

\n

we allow late binding of this private internal merge so that internalModelFactory\ncan insert itself here to handle elimination of duplicates

\n", + "itemtype": "method", + "name": "__configureMerge", + "access": "private", + "tagname": "", + "class": "IdentifierCache", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 153, + "itemtype": "method", + "name": "_getRecordIdentifier", + "access": "private", + "tagname": "", + "class": "IdentifierCache", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 278, + "description": "

allows us to peek without generating when needed\nuseful for the "create" case when we need to see if\nwe are accidentally overwritting something

\n", + "itemtype": "method", + "name": "peekRecordIdentifier", + "params": [ + { + "name": "resource", + "description": "" + } + ], + "return": { + "description": "", + "type": "StableRecordIdentifier | undefined" + }, + "access": "private", + "tagname": "", + "class": "IdentifierCache", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 292, + "description": "

Returns the Identifier for the given Resource, creates one if it does not yet exist.

\n

Specifically this means that we:

\n\n", + "itemtype": "method", + "name": "getOrCreateRecordIdentifier", + "params": [ + { + "name": "resource", + "description": "" + } + ], + "return": { + "description": "", + "type": "StableRecordIdentifier" + }, + "access": "public", + "tagname": "", + "class": "IdentifierCache", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 313, + "description": "

Returns a new Identifier for the supplied data. Call this method to generate\nan identifier when a new resource is being created local to the client and\npotentially does not have an id.

\n

Delegates generation to the user supplied GenerateMethod if one has been provided\nwith the signature generateMethod({ type }, 'record').

\n", + "itemtype": "method", + "name": "createIdentifierForNewRecord", + "params": [ + { + "name": "data", + "description": "" + } + ], + "return": { + "description": "", + "type": "StableRecordIdentifier" + }, + "access": "public", + "tagname": "", + "class": "IdentifierCache", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 348, + "description": "

Provides the opportunity to update secondary lookup tables for existing identifiers\nCalled after an identifier created with createIdentifierForNewRecord has been\ncommitted.

\n

Assigned id to an Identifier if id has not previously existed; however,\nattempting to change the id or calling update without providing an id when\none is missing will throw an error.

\n\n

If a merge occurs, it is possible the returned identifier does not match the originally\n provided identifier. In this case the abandoned identifier will go through the usual\n forgetRecordIdentifier codepaths.

\n", + "itemtype": "method", + "name": "updateRecordIdentifier", + "params": [ + { + "name": "identifierObject", + "description": "" + }, + { + "name": "data", + "description": "" + } + ], + "return": { + "description": "", + "type": "StableRecordIdentifier" + }, + "access": "public", + "tagname": "", + "class": "IdentifierCache", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 412, + "itemtype": "method", + "name": "_mergeRecordIdentifiers", + "access": "private", + "tagname": "", + "class": "IdentifierCache", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/identifiers/cache.ts", + "line": 442, + "description": "

Provides the opportunity to eliminate an identifier from secondary lookup tables\nas well as eliminates it from ember-data's own lookup tables and book keeping.

\n

Useful when a record has been deleted and the deletion has been persisted and\nwe do not care about the record anymore. Especially useful when an id of a\ndeleted record might be reused later for a new record.

\n", + "itemtype": "method", + "name": "forgetRecordIdentifier", + "params": [ + { + "name": "identifierObject", + "description": "" + } + ], + "access": "public", + "tagname": "", + "class": "IdentifierCache", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-InvalidError-015c442b59.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-InvalidError-015c442b59.json new file mode 100644 index 000000000..c112693a8 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-InvalidError-015c442b59.json @@ -0,0 +1,49 @@ +{ + "data": { + "id": "ember-data-3.28.13-InvalidError", + "type": "class", + "attributes": { + "name": "InvalidError", + "shortname": "InvalidError", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter/error", + "namespace": "", + "file": "../adapter/addon/error.js", + "line": 122, + "description": "

A InvalidError is used by an adapter to signal the external API\nwas unable to process a request because the content was not\nsemantically correct or meaningful per the API. Usually, this means a\nrecord failed some form of server-side validation. When a promise\nfrom an adapter is rejected with a InvalidError the record will\ntransition to the invalid state and the errors will be set to the\nerrors property on the record.

\n

For Ember Data to correctly map errors to their corresponding\nproperties on the model, Ember Data expects each error to be\na valid JSON-API error object with a source/pointer that matches\nthe property name. For example, if you had a Post model that\nlooked like this.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n6\n
import Model, { attr } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @attr('string') title;\n  @attr('string') content;\n}
\n
\n
\n \n

To show an error from the server related to the title and\ncontent properties your adapter could return a promise that\nrejects with a InvalidError object that looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n
import RSVP from 'RSVP';\nimport RESTAdapter from '@ember-data/adapter/rest';\nimport { InvalidError } from '@ember-data/adapter/error';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  updateRecord() {\n    // Fictional adapter that always rejects\n    return RSVP.reject(new InvalidError([\n      {\n        detail: 'Must be unique',\n        source: { pointer: '/data/attributes/title' }\n      },\n      {\n        detail: 'Must not be blank',\n        source: { pointer: '/data/attributes/content'}\n      }\n    ]));\n  }\n}
\n
\n
\n \n

Your backend may use different property names for your records the\nstore will attempt to extract and normalize the errors using the\nserializer's extractErrors method before the errors get added to\nthe model. As a result, it is safe for the InvalidError to\nwrap the error payload unaltered.

\n", + "access": "public", + "tagname": "", + "extends": "AdapterError", + "methods": [], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-AdapterError", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/error", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONAPIAdapter-1d32cc56aa.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONAPIAdapter-1d32cc56aa.json new file mode 100644 index 000000000..56593daee --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONAPIAdapter-1d32cc56aa.json @@ -0,0 +1,1907 @@ +{ + "data": { + "id": "ember-data-3.28.13-JSONAPIAdapter", + "type": "class", + "attributes": { + "name": "JSONAPIAdapter", + "shortname": "JSONAPIAdapter", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter/json-api", + "namespace": "", + "file": "../adapter/addon/json-api.ts", + "line": 18, + "description": "

The JSONAPIAdapter is the default adapter used by Ember Data. It\nis responsible for transforming the store's requests into HTTP\nrequests that follow the JSON API\nformat.

\n

JSON API Conventions

\n

The JSONAPIAdapter uses JSON API conventions for building the URL\nfor a record and selecting the HTTP verb to use with a request. The\nactions you can take on a record map onto the following URLs in the\nJSON API adapter:

\n\n\n \n \n \n\n\n \n \n \n\n\n \n \n \n\n\n \n \n \n\n\n \n \n \n\n\n \n \n \n\n
\n Action\n \n HTTP Verb\n \n URL\n
\n `store.findRecord('post', 123)`\n \n GET\n \n /posts/123\n
\n `store.findAll('post')`\n \n GET\n \n /posts\n
\n Update `postRecord.save()`\n \n PATCH\n \n /posts/123\n
\n Create `store.createRecord('post').save()`\n \n POST\n \n /posts\n
\n Delete `postRecord.destroyRecord()`\n \n DELETE\n \n /posts/123\n
\n\n

Success and failure

\n

The JSONAPIAdapter will consider a success any response with a\nstatus code of the 2xx family ("Success"), as well as 304 ("Not\nModified"). Any other status code will be considered a failure.

\n

On success, the request promise will be resolved with the full\nresponse payload.

\n

Failed responses with status code 422 ("Unprocessable Entity") will\nbe considered "invalid". The response will be discarded, except for\nthe errors key. The request promise will be rejected with a\nInvalidError. This error object will encapsulate the saved\nerrors value.

\n

Any other status codes will be treated as an adapter error. The\nrequest promise will be rejected, similarly to the invalid case,\nbut with an instance of AdapterError instead.

\n

Endpoint path customization

\n

Endpoint paths can be prefixed with a namespace by setting the\nnamespace property on the adapter:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  namespace = 'api/1';\n}
\n
\n
\n \n

Requests for the person model would now target /api/1/people/1.

\n

Host customization

\n

An adapter can target other hosts by setting the host property.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  host = 'https://api.example.com';\n}
\n
\n
\n \n

Requests for the person model would now target\nhttps://api.example.com/people/1.

\n", + "since": "1.13.0", + "mainName": "@ember-data/adapter/json-api", + "tag": "main", + "_main": true, + "access": "public", + "tagname": "", + "is_constructor": 1, + "extends": "RESTAdapter", + "methods": [ + { + "file": "../adapter/addon/json-api.ts", + "line": 160, + "itemtype": "method", + "name": "ajaxOptions", + "access": "private", + "tagname": "", + "params": [ + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "type", + "description": "The request type GET, POST, PUT, DELETE etc.", + "type": "String" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/json-api" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 374, + "description": "

By default, the RESTAdapter will send the query params sorted alphabetically to the\nserver.

\n

For example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.query('posts', { sort: 'price', category: 'pets' });
\n
\n
\n \n

will generate a requests like this /posts?category=pets&sort=price, even if the\nparameters were specified in a different order.

\n

That way the generated URL will be deterministic and that simplifies caching mechanisms\nin the backend.

\n

Setting sortQueryParams to a falsey value will respect the original order.

\n

In case you want to sort the query parameters with a different criteria, set\nsortQueryParams to your custom sort function.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  sortQueryParams(params) {\n    let sortedKeys = Object.keys(params).sort().reverse();\n    let len = sortedKeys.length, newParams = {};\n\n    for (let i = 0; i < len; i++) {\n      newParams[sortedKeys[i]] = params[sortedKeys[i]];\n    }\n\n    return newParams;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "sortQueryParams", + "params": [ + { + "name": "obj", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 556, + "description": "

Called by the store in order to fetch the JSON for a given\ntype and ID.

\n

The findRecord method makes an Ajax request to a URL computed by\nbuildURL, and returns a promise for the resulting payload.

\n

This method performs an HTTP GET request with the id provided as part of the query string.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "findRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 581, + "description": "

Called by the store in order to fetch a JSON array for all\nof the records for a given type.

\n

The findAll method makes an Ajax (HTTP GET) request to a URL computed by buildURL, and returns a\npromise for the resulting payload.

\n", + "itemtype": "method", + "name": "findAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "neverSet", + "description": "a value is never provided to this argument", + "type": "Undefined" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 607, + "description": "

Called by the store in order to fetch a JSON array for\nthe records that match a particular query.

\n

The query method makes an Ajax (HTTP GET) request to a URL\ncomputed by buildURL, and returns a promise for the resulting\npayload.

\n

The query argument is a simple JavaScript object that will be passed directly\nto the server as parameters.

\n", + "itemtype": "method", + "name": "query", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "recordArray", + "description": "", + "type": "AdapterPopulatedRecordArray" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 637, + "description": "

Called by the store in order to fetch a JSON object for\nthe record that matches a particular query.

\n

The queryRecord method makes an Ajax (HTTP GET) request to a URL\ncomputed by buildURL, and returns a promise for the resulting\npayload.

\n

The query argument is a simple JavaScript object that will be passed directly\nto the server as parameters.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "queryRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 672, + "description": "

Called by the store in order to fetch several records together if coalesceFindRequests is true

\n

For example, if the original payload looks like:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "id": 1,\n  "title": "Rails is omakase",\n  "comments": [ 1, 2, 3 ]\n}
\n
\n
\n \n

The IDs will be passed as a URL-encoded Array of IDs, in this form:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
ids[]=1&ids[]=2&ids[]=3
\n
\n
\n \n

Many servers, such as Rails and PHP, will automatically convert this URL-encoded array\ninto an Array for you on the server-side. If you want to encode the\nIDs, differently, just override this (one-line) method.

\n

The findMany method makes an Ajax (HTTP GET) request to a URL computed by buildURL, and returns a\npromise for the resulting payload.

\n", + "itemtype": "method", + "name": "findMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "ids", + "description": "", + "type": "Array" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 711, + "description": "

Called by the store in order to fetch a JSON array for\nthe unloaded records in a has-many relationship that were originally\nspecified as a URL (inside of links).

\n

For example, if your original payload looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
{\n  "post": {\n    "id": 1,\n    "title": "Rails is omakase",\n    "links": { "comments": "/posts/1/comments" }\n  }\n}
\n
\n
\n \n

This method will be called with the parent record and /posts/1/comments.

\n

The findHasMany method will make an Ajax (HTTP GET) request to the originally specified URL.

\n

The format of your links value will influence the final request URL via the urlPrefix method:

\n\n", + "itemtype": "method", + "name": "findHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "relationship", + "description": "meta object describing the relationship", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 757, + "description": "

Called by the store in order to fetch the JSON for the unloaded record in a\nbelongs-to relationship that was originally specified as a URL (inside of\nlinks).

\n

For example, if your original payload looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
{\n  "person": {\n    "id": 1,\n    "name": "Tom Dale",\n    "links": { "group": "/people/1/group" }\n  }\n}
\n
\n
\n \n

This method will be called with the parent record and /people/1/group.

\n

The findBelongsTo method will make an Ajax (HTTP GET) request to the originally specified URL.

\n

The format of your links value will influence the final request URL via the urlPrefix method:

\n\n", + "itemtype": "method", + "name": "findBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "relationship", + "description": "meta object describing the relationship", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 802, + "description": "

Called by the store when a newly created record is\nsaved via the save method on a model record instance.

\n

The createRecord method serializes the record and makes an Ajax (HTTP POST) request\nto a URL computed by buildURL.

\n

See serialize for information on how to customize the serialized form\nof a record.

\n", + "itemtype": "method", + "name": "createRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 827, + "description": "

Called by the store when an existing record is saved\nvia the save method on a model record instance.

\n

The updateRecord method serializes the record and makes an Ajax (HTTP PUT) request\nto a URL computed by buildURL.

\n

See serialize for information on how to customize the serialized form\nof a record.

\n", + "itemtype": "method", + "name": "updateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 853, + "description": "

Called by the store when a record is deleted.

\n

The deleteRecord method makes an Ajax (HTTP DELETE) request to a URL computed by buildURL.

\n", + "itemtype": "method", + "name": "deleteRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 895, + "description": "

Organize records into groups, each of which is to be passed to separate\ncalls to findMany.

\n

This implementation groups together records that have the same base URL but\ndiffering ids. For example /comments/1 and /comments/2 will be grouped together\nbecause we know findMany can coalesce them together as /comments?ids[]=1&ids[]=2

\n

It also supports urls where ids are passed as a query param, such as /comments?id=1\nbut not those where there is more than 1 query param such as /comments?id=2&name=David\nCurrently only the query param of id is supported. If you need to support others, please\noverride this or the _stripIDFromURL method.

\n

It does not group records that have differing base urls, such as for example: /posts/1/comments/2\nand /posts/2/comments/3

\n", + "itemtype": "method", + "name": "groupRecordsForFindMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "an array of arrays of records, each of which is to be\n loaded separately by `findMany`.", + "type": "Array" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 964, + "description": "

Takes an ajax response, and returns the json payload or an error.

\n

By default this hook just returns the json payload passed to it.\nYou might want to override it in two cases:

\n
    \n
  1. Your API might return useful results in the response headers.\nResponse headers are passed in as the second argument.

    \n
  2. \n
  3. Your API might return errors as successful responses with status code\n200 and an Errors text or object. You can return a InvalidError or a\nAdapterError (or a sub class) from this hook and it will automatically\nreject the promise and put your record into the invalid or error state.

    \n
  4. \n
\n

Returning a InvalidError from this method will cause the\nrecord to transition into the invalid state and make the\nerrors object available on the record. When returning an\nInvalidError the store will attempt to normalize the error data\nreturned from the server using the serializer's extractErrors\nmethod.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "handleResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "requestData", + "description": "- the original request information", + "type": "Object" + } + ], + "return": { + "description": "response", + "type": "Object | AdapterError" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1027, + "description": "

Default handleResponse implementation uses this hook to decide if the\nresponse is a success.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "isSuccess", + "access": "public", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1043, + "description": "

Default handleResponse implementation uses this hook to decide if the\nresponse is an invalid error.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "isInvalid", + "access": "public", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1059, + "description": "

Takes a URL, an HTTP method and a hash of data, and makes an\nHTTP request.

\n

When the server responds with a payload, Ember Data will call into extractSingle\nor extractArray (depending on whether the original query was for one record or\nmany records).

\n

By default, ajax method has the following behavior:

\n\n", + "itemtype": "method", + "name": "ajax", + "access": "private", + "tagname": "", + "params": [ + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "type", + "description": "The request type GET, POST, PUT, DELETE etc.", + "type": "String" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1125, + "itemtype": "method", + "name": "_ajaxRequest", + "access": "private", + "tagname": "", + "params": [ + { + "name": "options", + "description": "jQuery ajax options to be used for the ajax request", + "type": "Object" + } + ], + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1157, + "itemtype": "method", + "name": "ajaxOptions", + "access": "private", + "tagname": "", + "params": [ + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "type", + "description": "The request type GET, POST, PUT, DELETE etc.", + "type": "String" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1232, + "itemtype": "method", + "name": "parseErrorResponse", + "access": "private", + "tagname": "", + "params": [ + { + "name": "responseText", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1250, + "itemtype": "method", + "name": "normalizeErrorResponse", + "access": "private", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "errors payload", + "type": "Array" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1272, + "description": "

Generates a detailed ("friendly") error message, with plenty\nof information for debugging (good luck!)

\n", + "itemtype": "method", + "name": "generatedDetailedMessage", + "access": "private", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "requestData", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "detailed error message", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1304, + "description": "

Used by findAll and findRecord to build the query's data hash\nsupplied to the ajax method.

\n", + "itemtype": "method", + "name": "buildQuery", + "since": "2.5.0", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 232, + "description": "

The findRecord() method is invoked when the store is asked for a record that\nhas not previously been loaded. In response to findRecord() being called, you\nshould query your persistence layer for a record with the given ID. The findRecord\nmethod should return a promise that will resolve to a JavaScript object that will be\nnormalized by the serializer.

\n

Here is an example of the findRecord implementation:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findRecord(store, type, id, snapshot) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}/${id}`).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 275, + "description": "

The findAll() method is used to retrieve all records for a given type.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findAll(store, type) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "neverSet", + "description": "a value is never provided to this argument", + "type": "Undefined" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 314, + "description": "

This method is called when you call query on the store.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  query(store, type, query) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`, query).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "query", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "recordArray", + "description": "", + "type": "AdapterPopulatedRecordArray" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 354, + "description": "

The queryRecord() method is invoked when the store is asked for a single\nrecord through a query object.

\n

In response to queryRecord() being called, you should always fetch fresh\ndata. Once found, you can asynchronously call the store's push() method\nto push the record into the store.

\n

Here is an example queryRecord implementation:

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter, { BuildURLMixin } from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) {\n  queryRecord(store, type, query) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`, query).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "queryRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Subclass of Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 400, + "description": "

If the globally unique IDs for your records should be generated on the client,\nimplement the generateIdForRecord() method. This method will be invoked\neach time you create a new record, and the value returned from it will be\nassigned to the record's primaryKey.

\n

Most traditional REST-like HTTP APIs will not use this method. Instead, the ID\nof the record will be set by the server, and your adapter will update the store\nwith the new ID when it calls didCreateRecord(). Only implement this method if\nyou intend to generate record IDs on the client-side.

\n

The generateIdForRecord() method will be invoked with the requesting store as\nthe first parameter and the newly created record as the second parameter:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
import Adapter from '@ember-data/adapter';\nimport { v4 } from 'uuid';\n\nexport default class ApplicationAdapter extends Adapter {\n  generateIdForRecord(store, type, inputProperties) {\n    return v4();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "generateIdForRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "inputProperties", + "description": "a hash of properties to set on the\n newly created record.", + "type": "Object" + } + ], + "return": { + "description": "id", + "type": "(String|Number)" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 434, + "description": "

Proxies to the serializer's serialize method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import Adapter from '@ember-data/adapter';\n\nexport default class ApplicationAdapter extends Adapter {\n  createRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let url = `/${type.modelName}`;\n\n    // ...\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "serialized snapshot", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 462, + "description": "

Implement this method in a subclass to handle the creation of\nnew records.

\n

Serializes the record and sends it to the server.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  createRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n\n    return new RSVP.Promise(function (resolve, reject) {\n      $.ajax({\n        type: 'POST',\n        url: `/${type.modelName}`,\n        dataType: 'json',\n        data: data\n      }).then(function (data) {\n        run(null, resolve, data);\n      }, function (jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "createRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 512, + "description": "

Implement this method in a subclass to handle the updating of\na record.

\n

Serializes the record update and sends it to the server.

\n

The updateRecord method is expected to return a promise that will\nresolve with the serialized record. This allows the backend to\ninform the Ember Data store the current state of this record after\nthe update. If it is not possible to return a serialized record\nthe updateRecord promise can also resolve with undefined and the\nEmber Data store will assume all of the updates were successfully\napplied on the backend.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  updateRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let id = snapshot.id;\n\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'PUT',\n        url: `/${type.modelName}/${id}`,\n        dataType: 'json',\n        data: data\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "updateRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 571, + "description": "

Implement this method in a subclass to handle the deletion of\na record.

\n

Sends a delete request for the record to the server.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  deleteRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let id = snapshot.id;\n\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'DELETE',\n        url: `/${type.modelName}/${id}`,\n        dataType: 'json',\n        data: data\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deleteRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 644, + "description": "

The store will call findMany instead of multiple findRecord\nrequests to find multiple records at once if coalesceFindRequests\nis true.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findMany(store, type, ids, snapshots) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'GET',\n        url: `/${type.modelName}/`,\n        dataType: 'json',\n        data: { filter: { id: ids.join(',') } }\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findMany", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the records", + "type": "Model" + }, + { + "name": "ids", + "description": "", + "type": "Array" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 683, + "description": "

Organize records into groups, each of which is to be passed to separate\ncalls to findMany.

\n

For example, if your API has nested URLs that depend on the parent, you will\nwant to group records by their parent.

\n

The default implementation returns the records as a single group.

\n", + "itemtype": "method", + "name": "groupRecordsForFindMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "an array of arrays of records, each of which is to be\n loaded separately by `findMany`.", + "type": "Array" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 703, + "description": "

This method is used by the store to determine if the store should\nreload a record from the adapter when a record is requested by\nstore.findRecord.

\n

If this method returns true, the store will re-fetch a record from\nthe adapter. If this method returns false, the store will resolve\nimmediately using the cached record.

\n

For example, if you are building an events ticketing system, in which users\ncan only reserve tickets for 20 minutes at a time, and want to ensure that\nin each route you have data that is no more than 20 minutes old you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
shouldReloadRecord(store, ticketSnapshot) {\n  let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');\n  let timeDiff = moment().diff(lastAccessedAt, 'minutes');\n\n  if (timeDiff > 20) {\n    return true;\n  } else {\n    return false;\n  }\n}
\n
\n
\n \n

This method would ensure that whenever you do store.findRecord('ticket', id) you will always get a ticket that is no more than 20 minutes old. In\ncase the cached version is more than 20 minutes old, findRecord will not\nresolve until you fetched the latest version.

\n

By default this hook returns false, as most UIs should not block user\ninteractions while waiting on data update.

\n

Note that, with default settings, shouldBackgroundReloadRecord will always\nre-fetch the records in the background even if shouldReloadRecord returns\nfalse. You can override shouldBackgroundReloadRecord if this does not\nsuit your use case.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldReloadRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 754, + "description": "

This method is used by the store to determine if the store should\nreload all records from the adapter when records are requested by\nstore.findAll.

\n

If this method returns true, the store will re-fetch all records from\nthe adapter. If this method returns false, the store will resolve\nimmediately using the cached records.

\n

For example, if you are building an events ticketing system, in which users\ncan only reserve tickets for 20 minutes at a time, and want to ensure that\nin each route you have data that is no more than 20 minutes old you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
shouldReloadAll(store, snapshotArray) {\n  let snapshots = snapshotArray.snapshots();\n\n  return snapshots.any((ticketSnapshot) => {\n    let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');\n    let timeDiff = moment().diff(lastAccessedAt, 'minutes');\n\n    if (timeDiff > 20) {\n      return true;\n    } else {\n      return false;\n    }\n  });\n}
\n
\n
\n \n

This method would ensure that whenever you do store.findAll('ticket') you\nwill always get a list of tickets that are no more than 20 minutes old. In\ncase a cached version is more than 20 minutes old, findAll will not\nresolve until you fetched the latest versions.

\n

By default, this method returns true if the passed snapshotRecordArray\nis empty (meaning that there are no records locally available yet),\notherwise, it returns false.

\n

Note that, with default settings, shouldBackgroundReloadAll will always\nre-fetch all the records in the background even if shouldReloadAll returns\nfalse. You can override shouldBackgroundReloadAll if this does not suit\nyour use case.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldReloadAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 810, + "description": "

This method is used by the store to determine if the store should\nreload a record after the store.findRecord method resolves a\ncached record.

\n

This method is only checked by the store when the store is\nreturning a cached record.

\n

If this method returns true the store will re-fetch a record from\nthe adapter.

\n

For example, if you do not want to fetch complex data over a mobile\nconnection, or if the network is down, you can implement\nshouldBackgroundReloadRecord as follows:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
shouldBackgroundReloadRecord(store, snapshot) {\n  let { downlink, effectiveType } = navigator.connection;\n\n  return downlink > 0 && effectiveType === '4g';\n}
\n
\n
\n \n

By default, this hook returns true so the data for the record is updated\nin the background.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldBackgroundReloadRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 847, + "description": "

This method is used by the store to determine if the store should\nreload a record array after the store.findAll method resolves\nwith a cached record array.

\n

This method is only checked by the store when the store is\nreturning a cached record array.

\n

If this method returns true the store will re-fetch all records\nfrom the adapter.

\n

For example, if you do not want to fetch complex data over a mobile\nconnection, or if the network is down, you can implement\nshouldBackgroundReloadAll as follows:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
shouldBackgroundReloadAll(store, snapshotArray) {\n  let { downlink, effectiveType } = navigator.connection;\n\n  return downlink > 0 && effectiveType === '4g';\n}
\n
\n
\n \n

By default this method returns true, indicating that a background reload\nshould always be triggered.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldBackgroundReloadAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 42, + "description": "

Builds a URL for a given type and optional ID.

\n

By default, it pluralizes the type's name (for example, 'post'\nbecomes 'posts' and 'person' becomes 'people'). To override the\npluralization see pathForType.

\n

If an ID is specified, it adds the ID to the path generated\nfor the type, separated by a /.

\n

When called by RESTAdapter.findMany() the id and snapshot parameters\nwill be arrays of ids and snapshots.

\n", + "itemtype": "method", + "name": "buildURL", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "single id or array of ids or query", + "type": "(String|Array|Object)" + }, + { + "name": "snapshot", + "description": "single snapshot or array of snapshots", + "type": "(Snapshot|SnapshotRecordArray)" + }, + { + "name": "requestType", + "description": "", + "type": "String" + }, + { + "name": "query", + "description": "object of query parameters to send for query requests.", + "type": "Object" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 97, + "itemtype": "method", + "name": "_buildURL", + "access": "private", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 132, + "description": "

Builds a URL for a store.findRecord(type, id) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/user.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindRecord(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id, snapshot);\n    return `${baseUrl}/users/${snapshot.adapterOptions.user_id}/playlists/${id}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 160, + "description": "

Builds a URL for a store.findAll(type) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindAll(modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName);\n    return `${baseUrl}/data/comments.json`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 186, + "description": "

Builds a URL for a store.query(type, query) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  host = 'https://api.github.com';\n  urlForQuery (query, modelName) {\n    switch(modelName) {\n      case 'repo':\n        return `https://api.github.com/orgs/${query.orgId}/repos`;\n      default:\n        return super.urlForQuery(...arguments);\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForQuery", + "access": "public", + "tagname": "", + "params": [ + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 217, + "description": "

Builds a URL for a store.queryRecord(type, query) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForQueryRecord({ slug }, modelName) {\n    let baseUrl = this.buildURL();\n    return `${baseUrl}/${encodeURIComponent(slug)}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForQueryRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 243, + "description": "

Builds a URL for coalescing multiple store.findRecord(type, id)\nrecords into 1 request when the adapter's coalesceFindRequests\nproperty is true.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForFindMany(ids, modelName) {\n    let baseUrl = this.buildURL();\n    return `${baseUrl}/coalesce`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "ids", + "description": "", + "type": "Array" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 272, + "description": "

Builds a URL for fetching an async hasMany relationship when a URL\nis not provided by the server.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindHasMany(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id);\n    return `${baseUrl}/relationships`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 300, + "description": "

Builds a URL for fetching an async belongsTo relationship when a url\nis not provided by the server.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindBelongsTo(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id);\n    return `${baseUrl}/relationships`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 328, + "description": "

Builds a URL for a record.save() call when the record was created\nlocally using store.createRecord().

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForCreateRecord(modelName, snapshot) {\n    return super.urlForCreateRecord(...arguments) + '/new';\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForCreateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 354, + "description": "

Builds a URL for a record.save() call when the record has been updated locally.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForUpdateRecord(id, modelName, snapshot) {\n    return `/${id}/feed?access_token=${snapshot.adapterOptions.token}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForUpdateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 380, + "description": "

Builds a URL for a record.save() call when the record has been deleted locally.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForDeleteRecord(id, modelName, snapshot) {\n    return super.urlForDeleteRecord(...arguments) + '/destroy';\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForDeleteRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 406, + "itemtype": "method", + "name": "urlPrefix", + "access": "private", + "tagname": "", + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "parentURL", + "description": "", + "type": "String" + } + ], + "return": { + "description": "urlPrefix", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 447, + "description": "

Determines the pathname for a given type.

\n

By default, it pluralizes the type's name (for example,\n'post' becomes 'posts' and 'person' becomes 'people').

\n

Pathname customization

\n

For example, if you have an object LineItem with an\nendpoint of /line_items/.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { decamelize } from '@ember/string';\nimport { pluralize } from 'ember-inflector';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  pathForType(modelName) {\n    var decamelized = decamelize(modelName);\n    return pluralize(decamelized);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "pathForType", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "path", + "type": "String" + }, + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + } + ], + "events": [], + "properties": [ + { + "file": "../adapter/addon/json-api.ts", + "line": 180, + "description": "

By default the JSONAPIAdapter will send each find request coming from a store.find\nor from accessing a relationship separately to the server. If your server supports passing\nids as a query string, you can set coalesceFindRequests to true to coalesce all find requests\nwithin a single runloop.

\n

For example, if you have an initial payload of:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
{\n  data: {\n    id: 1,\n    type: 'post',\n    relationship: {\n      comments: {\n        data: [\n          { id: 1, type: 'comment' },\n          { id: 2, type: 'comment' }\n        ]\n      }\n    }\n  }\n}
\n
\n
\n \n

By default calling post.get('comments') will trigger the following requests(assuming the\ncomments haven't been loaded before):

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
GET /comments/1\nGET /comments/2
\n
\n
\n \n

If you set coalesceFindRequests to true it will instead trigger the following request:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
GET /comments?filter[id]=1,2
\n
\n
\n \n

Setting coalesceFindRequests to true also works for store.find requests and belongsTo\nrelationships accessed within the same runloop. If you set coalesceFindRequests: true

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.findRecord('comment', 1);\nstore.findRecord('comment', 2);
\n
\n
\n \n

will also send a request to: GET /comments?filter[id]=1,2

\n

Note: Requests coalescing rely on URL building strategy. So if you override buildURL in your app\ngroupRecordsForFindMany more likely should be overridden as well in order for coalescing to work.

\n", + "itemtype": "property", + "name": "coalesceFindRequests", + "access": "public", + "tagname": "", + "type": "{boolean}", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/json-api" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 342, + "description": "

If jQuery or nAjax are installed, this property\n allows fetch to still be used instead when true.

\n", + "itemtype": "property", + "name": "useFetch", + "type": "{Boolean}", + "access": "public", + "tagname": "", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 432, + "description": "

By default the RESTAdapter will send each find request coming from a store.find\nor from accessing a relationship separately to the server. If your server supports passing\nids as a query string, you can set coalesceFindRequests to true to coalesce all find requests\nwithin a single runloop.

\n

For example, if you have an initial payload of:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
{\n  post: {\n    id: 1,\n    comments: [1, 2]\n  }\n}
\n
\n
\n \n

By default calling post.get('comments') will trigger the following requests(assuming the\ncomments haven't been loaded before):

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
GET /comments/1\nGET /comments/2
\n
\n
\n \n

If you set coalesceFindRequests to true it will instead trigger the following request:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
GET /comments?ids[]=1&ids[]=2
\n
\n
\n \n

Setting coalesceFindRequests to true also works for store.find requests and belongsTo\nrelationships accessed within the same runloop. If you set coalesceFindRequests: true

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.findRecord('comment', 1);\nstore.findRecord('comment', 2);
\n
\n
\n \n

will also send a request to: GET /comments?ids[]=1&ids[]=2

\n

Note: Requests coalescing rely on URL building strategy. So if you override buildURL in your app\ngroupRecordsForFindMany more likely should be overridden as well in order for coalescing to work.

\n", + "itemtype": "property", + "name": "coalesceFindRequests", + "access": "public", + "tagname": "", + "type": "{boolean}", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 492, + "description": "

Endpoint paths can be prefixed with a namespace by setting the namespace\nproperty on the adapter:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  namespace = 'api/1';\n}
\n
\n
\n \n

Requests for the Post model would now target /api/1/post/.

\n", + "itemtype": "property", + "name": "namespace", + "access": "public", + "tagname": "", + "type": "{String}", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 511, + "description": "

An adapter can target other hosts by setting the host property.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  host = 'https://api.example.com';\n}
\n
\n
\n \n

Requests for the Post model would now target https://api.example.com/post/.

\n", + "itemtype": "property", + "name": "host", + "access": "public", + "tagname": "", + "type": "{String}", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 529, + "description": "

Some APIs require HTTP headers, e.g. to provide an API\nkey. Arbitrary headers can be set as key/value pairs on the\nRESTAdapter's headers object and Ember Data will send them\nalong with each ajax request. For dynamic headers see headers\ncustomization.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { computed } from '@ember/object';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  headers: computed(function() {\n    return {\n      'API_KEY': 'secret key',\n      'ANOTHER_HEADER': 'Some header value'\n    };\n  })\n}
\n
\n
\n \n", + "itemtype": "property", + "name": "headers", + "access": "public", + "tagname": "", + "type": "{Object}", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter/rest", + "inherited": true, + "inheritedFrom": "RESTAdapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 208, + "description": "

If you would like your adapter to use a custom serializer you can\nset the defaultSerializer property to be the name of the custom\nserializer.

\n

Note the defaultSerializer serializer has a lower priority than\na model specific serializer (i.e. PostSerializer) or the\napplication serializer.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/django.js
1\n2\n3\n4\n5\n
import Adapter from '@ember-data/adapter';\n\nexport default Adapter.extend({\n  defaultSerializer: 'django'\n});
\n
\n
\n \n", + "deprecated": true, + "itemtype": "property", + "name": "defaultSerializer", + "access": "public", + "tagname": "", + "type": "{String}", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 622, + "description": "

By default the store will try to coalesce all fetchRecord calls within the same runloop\ninto as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call.\nYou can opt out of this behaviour by either not implementing the findMany hook or by setting\ncoalesceFindRequests to false.

\n", + "itemtype": "property", + "name": "coalesceFindRequests", + "access": "public", + "tagname": "", + "type": "{boolean}", + "class": "JSONAPIAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-RESTAdapter", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/json-api", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONAPISerializer-bd4f2cba28.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONAPISerializer-bd4f2cba28.json new file mode 100644 index 000000000..53abfe0d7 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONAPISerializer-bd4f2cba28.json @@ -0,0 +1,1955 @@ +{ + "data": { + "id": "ember-data-3.28.13-JSONAPISerializer", + "type": "class", + "attributes": { + "name": "JSONAPISerializer", + "shortname": "JSONAPISerializer", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer/json-api", + "namespace": "", + "file": "../serializer/addon/json-api.js", + "line": 15, + "description": "

Ember Data 2.0 Serializer:

\n

In Ember Data a Serializer is used to serialize and deserialize\nrecords when they are transferred in and out of an external source.\nThis process involves normalizing property names, transforming\nattribute values and serializing relationships.

\n

JSONAPISerializer supports the http://jsonapi.org/ spec and is the\nserializer recommended by Ember Data.

\n

This serializer normalizes a JSON API payload that looks like:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/player.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class Player extends Model {\n  @attr('string') name;\n  @attr('string') skill;\n  @attr('number') gamesPlayed;\n  @belongsTo('club') club;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/club.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr, hasMany } from '@ember-data/model';\n\nexport default class Club extends Model {\n  @attr('string') name;\n  @attr('string') location;\n  @hasMany('player') players;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n
  {\n    "data": [\n      {\n        "attributes": {\n          "name": "Benfica",\n          "location": "Portugal"\n        },\n        "id": "1",\n        "relationships": {\n          "players": {\n            "data": [\n              {\n                "id": "3",\n                "type": "players"\n              }\n            ]\n          }\n        },\n        "type": "clubs"\n      }\n    ],\n    "included": [\n      {\n        "attributes": {\n          "name": "Eusebio Silva Ferreira",\n          "skill": "Rocket shot",\n          "games-played": 431\n        },\n        "id": "3",\n        "relationships": {\n          "club": {\n            "data": {\n              "id": "1",\n              "type": "clubs"\n            }\n          }\n        },\n        "type": "players"\n      }\n    ]\n  }
\n
\n
\n \n

to the format that the Ember Data store expects.

\n

Customizing meta

\n

Since a JSON API Document can have meta defined in multiple locations you can\nuse the specific serializer hooks if you need to customize the meta.

\n

One scenario would be to camelCase the meta keys of your payload. The example\nbelow shows how this could be done using normalizeArrayResponse and\nextractRelationship.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n
import JSONAPISerializer from '@ember-data/serializer/json-api';\n\nexport default class ApplicationSerializer extends JSONAPISerializer {\n  normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {\n    let normalizedDocument = super.normalizeArrayResponse(...arguments);\n\n    // Customize document meta\n    normalizedDocument.meta = camelCaseKeys(normalizedDocument.meta);\n\n    return normalizedDocument;\n  }\n\n  extractRelationship(relationshipHash) {\n    let normalizedRelationship = super.extractRelationship(...arguments);\n\n    // Customize relationship meta\n    normalizedRelationship.meta = camelCaseKeys(normalizedRelationship.meta);\n\n    return normalizedRelationship;\n  }\n}
\n
\n
\n \n

@mainName @ember-data/serializer/json-api\n @tag main

\n", + "_main": true, + "since": "1.13.0", + "access": "public", + "tagname": "", + "extends": "JSONSerializer", + "methods": [ + { + "file": "../serializer/addon/json-api.js", + "line": 135, + "itemtype": "method", + "name": "_normalizeDocumentHelper", + "params": [ + { + "name": "documentHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 172, + "itemtype": "method", + "name": "_normalizeRelationshipDataHelper", + "params": [ + { + "name": "relationshipDataHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 184, + "itemtype": "method", + "name": "_normalizeResourceHelper", + "params": [ + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 213, + "description": "

Normalize some data and push it into the store.

\n", + "itemtype": "method", + "name": "pushPayload", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 226, + "itemtype": "method", + "name": "_normalizeResponse", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + }, + { + "name": "isSingle", + "description": "", + "type": "Boolean" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 279, + "description": "

Returns a relationship formatted as a JSON-API "relationship object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n", + "itemtype": "method", + "name": "extractRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "relationshipHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 308, + "description": "

Returns the resource's relationships formatted as a JSON-API "relationships object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n", + "itemtype": "method", + "name": "extractRelationships", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 346, + "itemtype": "method", + "name": "_extractType", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Model" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "String" + }, + "access": "private", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 357, + "description": "

Dasherizes and singularizes the model name in the payload to match\nthe format Ember Data uses internally for the model name.

\n

For example the key posts would be converted to post and the\nkey studentAssesments would be converted to student-assesment.

\n", + "itemtype": "method", + "name": "modelNameFromPayloadKey", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "the model's modelName", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 373, + "description": "

Converts the model name to a pluralized version of the model name.

\n

For example post would be converted to posts and\nstudent-assesment would be converted to student-assesments.

\n", + "itemtype": "method", + "name": "payloadKeyFromModelName", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 410, + "description": "

keyForAttribute can be used to define rules for how to convert an\nattribute name in your model to a key in your JSON.\nBy default JSONAPISerializer follows the format used on the examples of\nhttp://jsonapi.org/format and uses dashes as the word separator in the JSON\nattribute keys.

\n

This behaviour can be easily customized by extending this method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPISerializer from '@ember-data/serializer/json-api';\nimport { dasherize } from '@ember/string';\n\nexport default class ApplicationSerializer extends JSONAPISerializer {\n  keyForAttribute(attr, method) {\n    return dasherize(attr).toUpperCase();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 442, + "description": "

keyForRelationship can be used to define a custom key when\nserializing and deserializing relationship properties.\nBy default JSONAPISerializer follows the format used on the examples of\nhttp://jsonapi.org/format and uses dashes as word separators in\nrelationship properties.

\n

This behaviour can be easily customized by extending this method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPISerializer from '@ember-data/serializer/json-api';\nimport { underscore } from '@ember/string';\n\nexport default class ApplicationSerializer extends JSONAPISerializer {\n  keyForRelationship(key, relationship, method) {\n    return underscore(key);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "typeClass", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json-api.js", + "line": 474, + "description": "

Called when a record is saved in order to convert the\nrecord into JSON.

\n

For example, consider this model:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @attr title;\n  @attr body;\n\n  @belongsTo('user', { async: false, inverse: null })\n  author;\n}
\n
\n
\n \n

The default serialization would create a JSON-API resource object like:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
{\n  "data": {\n    "type": "comments",\n    "attributes": {\n      "title": "Rails is unagi",\n      "body": "Rails? Omakase? O_O",\n    },\n    "relationships": {\n      "author": {\n        "data": {\n          "id": "12",\n          "type": "users"\n        }\n      }\n    }\n  }\n}
\n
\n
\n \n

By default, attributes are passed through as-is, unless\nyou specified an attribute type (attr('date')). If\nyou specify a transform, the JavaScript value will be\nserialized when inserted into the attributes hash.

\n

Belongs-to relationships are converted into JSON-API\nresource identifier objects.

\n

IDs

\n

serialize takes an options hash with a single option:\nincludeId. If this option is true, serialize will,\nby default include the ID in the JSON object it builds.

\n

The JSONAPIAdapter passes in includeId: true when serializing a record\nfor createRecord or updateRecord.

\n

Customization

\n

Your server may expect data in a different format than the\nbuilt-in serialization format.

\n

In that case, you can implement serialize yourself and\nreturn data formatted to match your API's expectations, or override\nthe invoked adapter method and do the serialization in the adapter directly\nby using the provided snapshot.

\n

If your API's format differs greatly from the JSON:API spec, you should\nconsider authoring your own adapter and serializer instead of extending\nthis class.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import JSONAPISerializer from '@ember-data/serializer/json-api';\n\nexport default class PostSerializer extends JSONAPISerializer {\n  serialize(snapshot, options) {\n    let json = {\n      POST_TTL: snapshot.attr('title'),\n      POST_BDY: snapshot.attr('body'),\n      POST_CMS: snapshot.hasMany('comments', { ids: true })\n    };\n\n    if (options.includeId) {\n      json.POST_ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}
\n
\n
\n \n

Customizing an App-Wide Serializer

\n

If you want to define a serializer for your entire\napplication, you'll probably want to use eachAttribute\nand eachRelationship on the record.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n
import JSONAPISerializer from '@ember-data/serializer/json-api';\nimport { singularize } from 'ember-inflector';\nimport { underscore } from '@ember/string';\n\nexport default class ApplicationSerializer extends JSONAPISerializer {\n  serialize(snapshot, options) {\n    let json = {};\n\n    snapshot.eachAttribute((name) => {\n      json[serverAttributeName(name)] = snapshot.attr(name);\n    });\n\n    snapshot.eachRelationship((name, relationship) => {\n      if (relationship.kind === 'hasMany') {\n        json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n      }\n    });\n\n    if (options.includeId) {\n      json.ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}\n\nfunction serverAttributeName(attribute) {\n  return underscore(attribute).toUpperCase();\n}\n\nfunction serverHasManyName(name) {\n  return serverAttributeName(singularize(name)) + '_IDS';\n}
\n
\n
\n \n

This serializer will generate JSON that looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "TITLE": "Rails is omakase",\n  "BODY": "Yep. Omakase.",\n  "COMMENT_IDS": [ "1", "2", "3" ]\n}
\n
\n
\n \n

Tweaking the Default Formatting

\n

If you just want to do some small tweaks on the default JSON:API formatted response,\nyou can call super.serialize first and make the tweaks\non the returned object.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONAPISerializer from '@ember-data/serializer/json-api';\n\nexport default class PostSerializer extends JSONAPISerializer {\n  serialize(snapshot, options) {\n    let json = super.serialize(...arguments);\n\n    json.data.attributes.subject = json.data.attributes.title;\n    delete json.data.attributes.title;\n\n    return json;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "json", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json-api" + }, + { + "file": "../serializer/addon/json.js", + "line": 182, + "description": "

Given a subclass of Model and a JSON object this method will\niterate through each attribute of the Model and invoke the\nTransform#deserialize method on the matching property of the\nJSON object. This method is typically called after the\nserializer's normalize method.

\n", + "itemtype": "method", + "name": "applyTransforms", + "access": "private", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "data", + "description": "The data to transform", + "type": "Object" + } + ], + "return": { + "description": "data The transformed data object", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 211, + "description": "

The normalizeResponse method is used to normalize a payload from the\nserver to a JSON-API Document.

\n

http://jsonapi.org/format/#document-structure

\n

This method delegates to a more specific normalize method based on\nthe requestType.

\n

To override this method with a custom one, make sure to call\nreturn this._super(store, primaryModelClass, payload, id, requestType) with your\npre-processed data.

\n

Here's an example of using normalizeResponse manually:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
socket.on('message', function(message) {\n  let data = message.data;\n  let modelClass = store.modelFor(data.modelName);\n  let serializer = store.serializerFor(data.modelName);\n  let normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id);\n\n  store.push(normalized);\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 272, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 290, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is queryRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeQueryRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 308, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findAll

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindAllResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 326, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findBelongsTo

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindBelongsToResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 344, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findHasMany

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindHasManyResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 362, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findMany

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindManyResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 380, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is query

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeQueryResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 398, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is createRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeCreateRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 416, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is deleteRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeDeleteRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 434, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is updateRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeUpdateRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 452, + "description": "

normalizeUpdateRecordResponse, normalizeCreateRecordResponse and\nnormalizeDeleteRecordResponse delegate to this method by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeSaveResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 470, + "description": "

normalizeQueryResponse and normalizeFindRecordResponse delegate to this\nmethod by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeSingleResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 488, + "description": "

normalizeQueryResponse, normalizeFindManyResponse, and normalizeFindHasManyResponse delegate\nto this method by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeArrayResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 506, + "itemtype": "method", + "name": "_normalizeResponse", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + }, + { + "name": "isSingle", + "description": "", + "type": "Boolean" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 555, + "description": "

Normalizes a part of the JSON payload returned by\nthe server. You should override this method, munge the hash\nand call super if you have generic normalization to do.

\n

It takes the type of the record that is being normalized\n(as a Model class), the property where the hash was\noriginally found, and the hash to normalize.

\n

You can use this method, for example, to normalize underscored keys to camelized\nor other general-purpose normalizations.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\nimport { get } from '@ember/object';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  normalize(typeClass, hash) {\n    let fields = get(typeClass, 'fields');\n\n    fields.forEach(function(type, field) {\n      let payloadField = underscore(field);\n      if (field === payloadField) { return; }\n\n      hash[field] = hash[payloadField];\n      delete hash[payloadField];\n    });\n\n    return this._super.apply(this, arguments);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "hash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 619, + "description": "

Returns the resource's ID.

\n", + "itemtype": "method", + "name": "extractId", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 634, + "description": "

Returns the resource's attributes formatted as a JSON-API "attributes object".

\n

http://jsonapi.org/format/#document-resource-object-attributes

\n", + "itemtype": "method", + "name": "extractAttributes", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 659, + "description": "

Returns a relationship formatted as a JSON-API "relationship object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n", + "itemtype": "method", + "name": "extractRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "relationshipModelName", + "description": "", + "type": "Object" + }, + { + "name": "relationshipHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 694, + "description": "

Returns a polymorphic relationship formatted as a JSON-API "relationship object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n

relationshipOptions is a hash which contains more information about the\npolymorphic relationship which should be extracted:

\n\n", + "itemtype": "method", + "name": "extractPolymorphicRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "relationshipModelName", + "description": "", + "type": "Object" + }, + { + "name": "relationshipHash", + "description": "", + "type": "Object" + }, + { + "name": "relationshipOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 718, + "description": "

Returns the resource's relationships formatted as a JSON-API "relationships object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n", + "itemtype": "method", + "name": "extractRelationships", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 790, + "description": "

Dasherizes the model name in the payload

\n", + "itemtype": "method", + "name": "modelNameFromPayloadKey", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "the model's modelName", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 802, + "itemtype": "method", + "name": "normalizeRelationships", + "access": "private", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 825, + "itemtype": "method", + "name": "normalizeUsingDeclaredMapping", + "access": "private", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 858, + "description": "

Looks up the property key that was set by the custom attr mapping\npassed to the serializer.

\n", + "itemtype": "method", + "name": "_getMappedKey", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "key", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 897, + "description": "

Check attrs.key.serialize property to inform if the key\ncan be serialized

\n", + "itemtype": "method", + "name": "_canSerialize", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the key can be serialized", + "type": "Boolean" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 912, + "description": "

When attrs.key.serialize is set to true then\nit takes priority over the other checks and the related\nattribute/relationship will be serialized

\n", + "itemtype": "method", + "name": "_mustSerialize", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the key must be serialized", + "type": "Boolean" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 928, + "description": "

Check if the given hasMany relationship should be serialized

\n

By default only many-to-many and many-to-none relationships are serialized.\nThis could be configured per relationship by Serializer's attrs object.

\n", + "itemtype": "method", + "name": "shouldSerializeHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "relationshipType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the hasMany relationship should be serialized", + "type": "Boolean" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 950, + "description": "

Called when a record is saved in order to convert the\nrecord into JSON.

\n

By default, it creates a JSON object with a key for\neach attribute and belongsTo relationship.

\n

For example, consider this model:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @attr title;\n  @attr body;\n\n  @belongsTo('user') author;\n}
\n
\n
\n \n

The default serialization would create a JSON object like:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "title": "Rails is unagi",\n  "body": "Rails? Omakase? O_O",\n  "author": 12\n}
\n
\n
\n \n

By default, attributes are passed through as-is, unless\nyou specified an attribute type (attr('date')). If\nyou specify a transform, the JavaScript value will be\nserialized when inserted into the JSON hash.

\n

By default, belongs-to relationships are converted into\nIDs when inserted into the JSON hash.

\n

IDs

\n

serialize takes an options hash with a single option:\nincludeId. If this option is true, serialize will,\nby default include the ID in the JSON object it builds.

\n

The adapter passes in includeId: true when serializing\na record for createRecord, but not for updateRecord.

\n

Customization

\n

Your server may expect a different JSON format than the\nbuilt-in serialization format.

\n

In that case, you can implement serialize yourself and\nreturn a JSON hash of your choosing.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = {\n      POST_TTL: snapshot.attr('title'),\n      POST_BDY: snapshot.attr('body'),\n      POST_CMS: snapshot.hasMany('comments', { ids: true })\n    };\n\n    if (options.includeId) {\n      json.POST_ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}
\n
\n
\n \n

Customizing an App-Wide Serializer

\n

If you want to define a serializer for your entire\napplication, you'll probably want to use eachAttribute\nand eachRelationship on the record.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { singularize } from 'ember-inflector';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = {};\n\n    snapshot.eachAttribute((name) => {\n      json[serverAttributeName(name)] = snapshot.attr(name);\n    });\n\n    snapshot.eachRelationship((name, relationship) => {\n      if (relationship.kind === 'hasMany') {\n        json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n      }\n    });\n\n    if (options.includeId) {\n      json.ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}\n\nfunction serverAttributeName(attribute) {\n  return attribute.underscore().toUpperCase();\n}\n\nfunction serverHasManyName(name) {\n  return serverAttributeName(singularize(name)) + "_IDS";\n}
\n
\n
\n \n

This serializer will generate JSON that looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "TITLE": "Rails is omakase",\n  "BODY": "Yep. Omakase.",\n  "COMMENT_IDS": [ "1", "2", "3" ]\n}
\n
\n
\n \n

Tweaking the Default JSON

\n

If you just want to do some small tweaks on the default JSON,\nyou can call super.serialize first and make the tweaks on\nthe returned JSON.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = super.serialize(...arguments);\n\n    json.subject = json.title;\n    delete json.title;\n\n    return json;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "json", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1128, + "description": "

You can use this method to customize how a serialized record is added to the complete\nJSON hash to be sent to the server. By default the JSON Serializer does not namespace\nthe payload and just sends the raw serialized JSON object.\nIf your server expects namespaced keys, you should consider using the RESTSerializer.\nOtherwise you can override this method to customize how the record is added to the hash.\nThe hash property should be modified by reference.

\n

For example, your server may expect underscored root objects.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { decamelize } from '@ember/string';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  serializeIntoHash(data, type, snapshot, options) {\n    let root = decamelize(type.modelName);\n    data[root] = this.serialize(snapshot, options);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeIntoHash", + "access": "public", + "tagname": "", + "params": [ + { + "name": "hash", + "description": "", + "type": "Object" + }, + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1161, + "description": "

serializeAttribute can be used to customize how attr\nproperties are serialized

\n

For example if you wanted to ensure all your attributes were always\nserialized as properties on an attributes object you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  serializeAttribute(snapshot, json, key, attributes) {\n    json.attributes = json.attributes || {};\n    this._super(snapshot, json.attributes, key, attributes);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "attribute", + "description": "", + "type": "Object" + } + ], + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1208, + "description": "

serializeBelongsTo can be used to customize how belongsTo\nproperties are serialized.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { isNone } from '@ember/utils';\n\nexport default class PostSerializer extends JSONSerializer {\n  serializeBelongsTo(snapshot, json, relationship) {\n    let key = relationship.key;\n    let belongsTo = snapshot.belongsTo(key);\n\n    key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key;\n\n    json[key] = isNone(belongsTo) ? belongsTo : belongsTo.record.toJSON();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1262, + "description": "

serializeHasMany can be used to customize how hasMany\nproperties are serialized.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serializeHasMany(snapshot, json, relationship) {\n    let key = relationship.key;\n    if (key === 'comments') {\n      return;\n    } else {\n      this._super(...arguments);\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1308, + "description": "

You can use this method to customize how polymorphic objects are\nserialized. Objects are considered to be polymorphic if\n{ polymorphic: true } is pass as the second argument to the\nbelongsTo function.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { isNone } from '@ember/utils';\n\nexport default class CommentSerializer extends JSONSerializer {\n  serializePolymorphicType(snapshot, json, relationship) {\n    let key = relationship.key;\n    let belongsTo = snapshot.belongsTo(key);\n\n    key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key;\n\n    if (isNone(belongsTo)) {\n      json[key + '_type'] = null;\n    } else {\n      json[key + '_type'] = belongsTo.modelName;\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializePolymorphicType", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1344, + "description": "

extractMeta is used to deserialize any meta information in the\nadapter payload. By default Ember Data expects meta information to\nbe located on the meta property of the payload object.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  extractMeta(store, typeClass, payload) {\n    if (payload && payload.hasOwnProperty('_pagination')) {\n      let meta = payload._pagination;\n      delete payload._pagination;\n      return meta;\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "extractMeta", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "modelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1379, + "description": "

extractErrors is used to extract model errors when a call\nto Model#save fails with an InvalidError. By default\nEmber Data expects error information to be located on the errors\nproperty of the payload object.

\n

This serializer expects this errors object to be an Array similar\nto the following, compliant with the https://jsonapi.org/format/#errors specification:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
{\n  "errors": [\n    {\n      "detail": "This username is already taken!",\n      "source": {\n        "pointer": "data/attributes/username"\n      }\n    }, {\n      "detail": "Doesn't look like a valid email.",\n      "source": {\n        "pointer": "data/attributes/email"\n      }\n    }\n  ]\n}
\n
\n
\n \n

The key detail provides a textual description of the problem.\nAlternatively, the key title can be used for the same purpose.

\n

The nested keys source.pointer detail which specific element\nof the request data was invalid.

\n

Note that JSON-API also allows for object-level errors to be placed\nin an object with pointer data, signifying that the problem\ncannot be traced to a specific attribute:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
{\n  "errors": [\n    {\n      "detail": "Some generic non property error message",\n      "source": {\n        "pointer": "data"\n      }\n    }\n  ]\n}
\n
\n
\n \n

When turn into a Errors object, you can read these errors\nthrough the property base:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{{#each @model.errors.base as |error|}}\n  <div class="error">\n    {{error.message}}\n  </div>\n{{/each}}
\n
\n
\n \n

Example of alternative implementation, overriding the default\nbehavior to deal with a different format of errors:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  extractErrors(store, typeClass, payload, id) {\n    if (payload && typeof payload === 'object' && payload._problems) {\n      payload = payload._problems;\n      this.normalizeErrors(typeClass, payload);\n    }\n    return payload;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "extractErrors", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "(String|Number)" + } + ], + "return": { + "description": "json The deserialized errors", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1491, + "description": "

keyForAttribute can be used to define rules for how to convert an\nattribute name in your model to a key in your JSON.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  keyForAttribute(attr, method) {\n    return underscore(attr).toUpperCase();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1518, + "description": "

keyForRelationship can be used to define a custom key when\nserializing and deserializing relationship properties. By default\nJSONSerializer does not provide an implementation of this method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\n\nexport default class PostSerializer extends JSONSerializer {\n  keyForRelationship(key, relationship, method) {\n    return `rel_${underscore(key)}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "typeClass", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1547, + "description": "

keyForLink can be used to define a custom key when deserializing link\nproperties.

\n", + "itemtype": "method", + "name": "keyForLink", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "kind", + "description": "`belongsTo` or `hasMany`", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1563, + "itemtype": "method", + "name": "transformFor", + "access": "private", + "tagname": "", + "params": [ + { + "name": "attributeType", + "description": "", + "type": "String" + }, + { + "name": "skipAssertion", + "description": "", + "type": "Boolean" + } + ], + "return": { + "description": "transform", + "type": "Transform" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 147, + "description": "

The normalizeResponse method is used to normalize a payload from the\nserver to a JSON-API Document.

\n

http://jsonapi.org/format/#document-structure

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
Serializer.extend({\n  normalizeResponse(store, primaryModelClass, payload, id, requestType) {\n    if (requestType === 'findRecord') {\n      return this.normalize(primaryModelClass, payload);\n    } else {\n      return payload.reduce(function(documentHash, item) {\n        let { data, included } = this.normalize(primaryModelClass, item);\n        documentHash.included.push(...included);\n        documentHash.data.push(data);\n        return documentHash;\n      }, { data: [], included: [] })\n    }\n  }\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 184, + "description": "

The serialize method is used when a record is saved in order to convert\nthe record into the form that your external data source expects.

\n

serialize takes an optional options hash with a single option:

\n\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n
Serializer.extend({\n  serialize(snapshot, options) {\n    let json = {\n      id: snapshot.id\n    };\n\n    snapshot.eachAttribute((key, attribute) => {\n      json[key] = snapshot.attr(key);\n    });\n\n    snapshot.eachRelationship((key, relationship) => {\n      if (relationship.kind === 'belongsTo') {\n        json[key] = snapshot.belongsTo(key, { id: true });\n      } else if (relationship.kind === 'hasMany') {\n        json[key] = snapshot.hasMany(key, { ids: true });\n      }\n    });\n\n    return json;\n  },\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object", + "optional": true + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 227, + "description": "

The normalize method is used to convert a payload received from your\nexternal data source into the normalized form store.push() expects. You\nshould override this method, munge the hash and return the normalized\npayload.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
Serializer.extend({\n  normalize(modelClass, resourceHash) {\n    let data = {\n      id:            resourceHash.id,\n      type:          modelClass.modelName,\n      attributes:    resourceHash\n    };\n    return { data: data };\n  }\n})
\n
\n
\n \n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "hash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONAPISerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + } + ], + "events": [], + "properties": [ + { + "file": "../serializer/addon/json.js", + "line": 88, + "description": "

The primaryKey is used when serializing and deserializing\ndata. Ember Data always uses the id property to store the id of\nthe record. The external source may not always follow this\nconvention. In these cases it is useful to override the\nprimaryKey property to match the primaryKey of your external\nstore.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  primaryKey = '_id'\n}
\n
\n
\n \n", + "itemtype": "property", + "name": "primaryKey", + "type": "{String}", + "access": "public", + "tagname": "", + "default": "'id'", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 113, + "description": "

The attrs object can be used to declare a simple mapping between\nproperty names on Model records and payload keys in the\nserialized JSON object representing the record. An object with the\nproperty key can also be used to designate the attribute's key on\nthe response payload.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr } from '@ember-data/model';\n\nexport default class PersonModel extends Model {\n  @attr('string') firstName;\n  @attr('string') lastName;\n  @attr('string') occupation;\n  @attr('boolean') admin;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PersonSerializer extends JSONSerializer {\n  attrs = {\n    admin: 'is_admin',\n    occupation: { key: 'career' }\n  }\n}
\n
\n
\n \n

You can also remove attributes and relationships by setting the serialize\nkey to false in your mapping object.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  attrs = {\n    admin: { serialize: false },\n    occupation: { key: 'career' }\n  }\n}
\n
\n
\n \n

When serialized:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "firstName": "Harry",\n  "lastName": "Houdini",\n  "career": "magician"\n}
\n
\n
\n \n

Note that the admin is now not included in the payload.

\n

Setting serialize to true enforces serialization for hasMany\nrelationships even if it's neither a many-to-many nor many-to-none\nrelationship.

\n", + "itemtype": "property", + "name": "attrs", + "access": "public", + "tagname": "", + "type": "{Object}", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 125, + "description": "

The store property is the application's store that contains\nall records. It can be used to look up serializers for other model\ntypes that may be nested inside the payload response.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
Serializer.extend({\n  extractRelationship(relationshipModelName, relationshipHash) {\n    let modelClass = this.store.modelFor(relationshipModelName);\n    let relationshipSerializer = this.store.serializerFor(relationshipModelName);\n    return relationshipSerializer.normalize(modelClass, relationshipHash);\n  }\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "store", + "type": "{Store}", + "access": "public", + "tagname": "", + "class": "JSONAPISerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-JSONSerializer", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer/json-api", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONSerializer-8566db9bca.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONSerializer-8566db9bca.json new file mode 100644 index 000000000..10d98628f --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-JSONSerializer-8566db9bca.json @@ -0,0 +1,1540 @@ +{ + "data": { + "id": "ember-data-3.28.13-JSONSerializer", + "type": "class", + "attributes": { + "name": "JSONSerializer", + "shortname": "JSONSerializer", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer/json", + "namespace": "", + "file": "../serializer/addon/json.js", + "line": 16, + "description": "

Ember Data 2.0 Serializer:

\n

In Ember Data a Serializer is used to serialize and deserialize\nrecords when they are transferred in and out of an external source.\nThis process involves normalizing property names, transforming\nattribute values and serializing relationships.

\n

By default, Ember Data uses and recommends the JSONAPISerializer.

\n

JSONSerializer is useful for simpler or legacy backends that may\nnot support the http://jsonapi.org/ spec.

\n

For example, given the following User model and JSON payload:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @hasMany('user') friends;\n  @belongsTo('location') house;\n\n  @attr('string') name;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
{\n  id: 1,\n  name: 'Sebastian',\n  friends: [3, 4],\n  links: {\n    house: '/houses/lefkada'\n  }\n}
\n
\n
\n \n

JSONSerializer will normalize the JSON payload to the JSON API format that the\nEmber Data store expects.

\n

You can customize how JSONSerializer processes its payload by passing options in\nthe attrs hash or by subclassing the JSONSerializer and overriding hooks:

\n\n

The JSONSerializer normalization process follows these steps:

\n
    \n
  1. normalizeResponse
      \n
    • entry method to the serializer.
    • \n
    \n
  2. \n
  3. normalizeCreateRecordResponse
      \n
    • a normalizeResponse for a specific operation is called.
    • \n
    \n
  4. \n
  5. normalizeSingleResponse|normalizeArrayResponse
      \n
    • for methods like createRecord we expect a single record back, while for methods like findAll we expect multiple records back.
    • \n
    \n
  6. \n
  7. normalize
      \n
    • normalizeArrayResponse iterates and calls normalize for each of its records while normalizeSingle\ncalls it once. This is the method you most likely want to subclass.
    • \n
    \n
  8. \n
  9. extractId | extractAttributes | extractRelationships
      \n
    • normalize delegates to these methods to\nturn the record payload into the JSON API format.\n @mainName @ember-data/serializer/json\n @tag main
    • \n
    \n
  10. \n
\n", + "_main": true, + "access": "public", + "tagname": "", + "extends": "Serializer", + "methods": [ + { + "file": "../serializer/addon/json.js", + "line": 182, + "description": "

Given a subclass of Model and a JSON object this method will\niterate through each attribute of the Model and invoke the\nTransform#deserialize method on the matching property of the\nJSON object. This method is typically called after the\nserializer's normalize method.

\n", + "itemtype": "method", + "name": "applyTransforms", + "access": "private", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "data", + "description": "The data to transform", + "type": "Object" + } + ], + "return": { + "description": "data The transformed data object", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 211, + "description": "

The normalizeResponse method is used to normalize a payload from the\nserver to a JSON-API Document.

\n

http://jsonapi.org/format/#document-structure

\n

This method delegates to a more specific normalize method based on\nthe requestType.

\n

To override this method with a custom one, make sure to call\nreturn this._super(store, primaryModelClass, payload, id, requestType) with your\npre-processed data.

\n

Here's an example of using normalizeResponse manually:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
socket.on('message', function(message) {\n  let data = message.data;\n  let modelClass = store.modelFor(data.modelName);\n  let serializer = store.serializerFor(data.modelName);\n  let normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id);\n\n  store.push(normalized);\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 272, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 290, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is queryRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeQueryRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 308, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findAll

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindAllResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 326, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findBelongsTo

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindBelongsToResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 344, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findHasMany

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindHasManyResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 362, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findMany

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindManyResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 380, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is query

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeQueryResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 398, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is createRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeCreateRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 416, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is deleteRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeDeleteRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 434, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is updateRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeUpdateRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 452, + "description": "

normalizeUpdateRecordResponse, normalizeCreateRecordResponse and\nnormalizeDeleteRecordResponse delegate to this method by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeSaveResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 470, + "description": "

normalizeQueryResponse and normalizeFindRecordResponse delegate to this\nmethod by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeSingleResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 488, + "description": "

normalizeQueryResponse, normalizeFindManyResponse, and normalizeFindHasManyResponse delegate\nto this method by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeArrayResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 506, + "itemtype": "method", + "name": "_normalizeResponse", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + }, + { + "name": "isSingle", + "description": "", + "type": "Boolean" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 555, + "description": "

Normalizes a part of the JSON payload returned by\nthe server. You should override this method, munge the hash\nand call super if you have generic normalization to do.

\n

It takes the type of the record that is being normalized\n(as a Model class), the property where the hash was\noriginally found, and the hash to normalize.

\n

You can use this method, for example, to normalize underscored keys to camelized\nor other general-purpose normalizations.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\nimport { get } from '@ember/object';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  normalize(typeClass, hash) {\n    let fields = get(typeClass, 'fields');\n\n    fields.forEach(function(type, field) {\n      let payloadField = underscore(field);\n      if (field === payloadField) { return; }\n\n      hash[field] = hash[payloadField];\n      delete hash[payloadField];\n    });\n\n    return this._super.apply(this, arguments);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "hash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 619, + "description": "

Returns the resource's ID.

\n", + "itemtype": "method", + "name": "extractId", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "String" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 634, + "description": "

Returns the resource's attributes formatted as a JSON-API "attributes object".

\n

http://jsonapi.org/format/#document-resource-object-attributes

\n", + "itemtype": "method", + "name": "extractAttributes", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 659, + "description": "

Returns a relationship formatted as a JSON-API "relationship object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n", + "itemtype": "method", + "name": "extractRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "relationshipModelName", + "description": "", + "type": "Object" + }, + { + "name": "relationshipHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 694, + "description": "

Returns a polymorphic relationship formatted as a JSON-API "relationship object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n

relationshipOptions is a hash which contains more information about the\npolymorphic relationship which should be extracted:

\n\n", + "itemtype": "method", + "name": "extractPolymorphicRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "relationshipModelName", + "description": "", + "type": "Object" + }, + { + "name": "relationshipHash", + "description": "", + "type": "Object" + }, + { + "name": "relationshipOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 718, + "description": "

Returns the resource's relationships formatted as a JSON-API "relationships object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n", + "itemtype": "method", + "name": "extractRelationships", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 790, + "description": "

Dasherizes the model name in the payload

\n", + "itemtype": "method", + "name": "modelNameFromPayloadKey", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "the model's modelName", + "type": "String" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 802, + "itemtype": "method", + "name": "normalizeRelationships", + "access": "private", + "tagname": "", + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 825, + "itemtype": "method", + "name": "normalizeUsingDeclaredMapping", + "access": "private", + "tagname": "", + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 858, + "description": "

Looks up the property key that was set by the custom attr mapping\npassed to the serializer.

\n", + "itemtype": "method", + "name": "_getMappedKey", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "key", + "type": "String" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 897, + "description": "

Check attrs.key.serialize property to inform if the key\ncan be serialized

\n", + "itemtype": "method", + "name": "_canSerialize", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the key can be serialized", + "type": "Boolean" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 912, + "description": "

When attrs.key.serialize is set to true then\nit takes priority over the other checks and the related\nattribute/relationship will be serialized

\n", + "itemtype": "method", + "name": "_mustSerialize", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the key must be serialized", + "type": "Boolean" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 928, + "description": "

Check if the given hasMany relationship should be serialized

\n

By default only many-to-many and many-to-none relationships are serialized.\nThis could be configured per relationship by Serializer's attrs object.

\n", + "itemtype": "method", + "name": "shouldSerializeHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "relationshipType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the hasMany relationship should be serialized", + "type": "Boolean" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 950, + "description": "

Called when a record is saved in order to convert the\nrecord into JSON.

\n

By default, it creates a JSON object with a key for\neach attribute and belongsTo relationship.

\n

For example, consider this model:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @attr title;\n  @attr body;\n\n  @belongsTo('user') author;\n}
\n
\n
\n \n

The default serialization would create a JSON object like:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "title": "Rails is unagi",\n  "body": "Rails? Omakase? O_O",\n  "author": 12\n}
\n
\n
\n \n

By default, attributes are passed through as-is, unless\nyou specified an attribute type (attr('date')). If\nyou specify a transform, the JavaScript value will be\nserialized when inserted into the JSON hash.

\n

By default, belongs-to relationships are converted into\nIDs when inserted into the JSON hash.

\n

IDs

\n

serialize takes an options hash with a single option:\nincludeId. If this option is true, serialize will,\nby default include the ID in the JSON object it builds.

\n

The adapter passes in includeId: true when serializing\na record for createRecord, but not for updateRecord.

\n

Customization

\n

Your server may expect a different JSON format than the\nbuilt-in serialization format.

\n

In that case, you can implement serialize yourself and\nreturn a JSON hash of your choosing.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = {\n      POST_TTL: snapshot.attr('title'),\n      POST_BDY: snapshot.attr('body'),\n      POST_CMS: snapshot.hasMany('comments', { ids: true })\n    };\n\n    if (options.includeId) {\n      json.POST_ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}
\n
\n
\n \n

Customizing an App-Wide Serializer

\n

If you want to define a serializer for your entire\napplication, you'll probably want to use eachAttribute\nand eachRelationship on the record.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { singularize } from 'ember-inflector';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = {};\n\n    snapshot.eachAttribute((name) => {\n      json[serverAttributeName(name)] = snapshot.attr(name);\n    });\n\n    snapshot.eachRelationship((name, relationship) => {\n      if (relationship.kind === 'hasMany') {\n        json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n      }\n    });\n\n    if (options.includeId) {\n      json.ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}\n\nfunction serverAttributeName(attribute) {\n  return attribute.underscore().toUpperCase();\n}\n\nfunction serverHasManyName(name) {\n  return serverAttributeName(singularize(name)) + "_IDS";\n}
\n
\n
\n \n

This serializer will generate JSON that looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "TITLE": "Rails is omakase",\n  "BODY": "Yep. Omakase.",\n  "COMMENT_IDS": [ "1", "2", "3" ]\n}
\n
\n
\n \n

Tweaking the Default JSON

\n

If you just want to do some small tweaks on the default JSON,\nyou can call super.serialize first and make the tweaks on\nthe returned JSON.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = super.serialize(...arguments);\n\n    json.subject = json.title;\n    delete json.title;\n\n    return json;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "json", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1128, + "description": "

You can use this method to customize how a serialized record is added to the complete\nJSON hash to be sent to the server. By default the JSON Serializer does not namespace\nthe payload and just sends the raw serialized JSON object.\nIf your server expects namespaced keys, you should consider using the RESTSerializer.\nOtherwise you can override this method to customize how the record is added to the hash.\nThe hash property should be modified by reference.

\n

For example, your server may expect underscored root objects.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { decamelize } from '@ember/string';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  serializeIntoHash(data, type, snapshot, options) {\n    let root = decamelize(type.modelName);\n    data[root] = this.serialize(snapshot, options);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeIntoHash", + "access": "public", + "tagname": "", + "params": [ + { + "name": "hash", + "description": "", + "type": "Object" + }, + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1161, + "description": "

serializeAttribute can be used to customize how attr\nproperties are serialized

\n

For example if you wanted to ensure all your attributes were always\nserialized as properties on an attributes object you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  serializeAttribute(snapshot, json, key, attributes) {\n    json.attributes = json.attributes || {};\n    this._super(snapshot, json.attributes, key, attributes);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "attribute", + "description": "", + "type": "Object" + } + ], + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1208, + "description": "

serializeBelongsTo can be used to customize how belongsTo\nproperties are serialized.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { isNone } from '@ember/utils';\n\nexport default class PostSerializer extends JSONSerializer {\n  serializeBelongsTo(snapshot, json, relationship) {\n    let key = relationship.key;\n    let belongsTo = snapshot.belongsTo(key);\n\n    key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key;\n\n    json[key] = isNone(belongsTo) ? belongsTo : belongsTo.record.toJSON();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1262, + "description": "

serializeHasMany can be used to customize how hasMany\nproperties are serialized.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serializeHasMany(snapshot, json, relationship) {\n    let key = relationship.key;\n    if (key === 'comments') {\n      return;\n    } else {\n      this._super(...arguments);\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1308, + "description": "

You can use this method to customize how polymorphic objects are\nserialized. Objects are considered to be polymorphic if\n{ polymorphic: true } is pass as the second argument to the\nbelongsTo function.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { isNone } from '@ember/utils';\n\nexport default class CommentSerializer extends JSONSerializer {\n  serializePolymorphicType(snapshot, json, relationship) {\n    let key = relationship.key;\n    let belongsTo = snapshot.belongsTo(key);\n\n    key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key;\n\n    if (isNone(belongsTo)) {\n      json[key + '_type'] = null;\n    } else {\n      json[key + '_type'] = belongsTo.modelName;\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializePolymorphicType", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1344, + "description": "

extractMeta is used to deserialize any meta information in the\nadapter payload. By default Ember Data expects meta information to\nbe located on the meta property of the payload object.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  extractMeta(store, typeClass, payload) {\n    if (payload && payload.hasOwnProperty('_pagination')) {\n      let meta = payload._pagination;\n      delete payload._pagination;\n      return meta;\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "extractMeta", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "modelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1379, + "description": "

extractErrors is used to extract model errors when a call\nto Model#save fails with an InvalidError. By default\nEmber Data expects error information to be located on the errors\nproperty of the payload object.

\n

This serializer expects this errors object to be an Array similar\nto the following, compliant with the https://jsonapi.org/format/#errors specification:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
{\n  "errors": [\n    {\n      "detail": "This username is already taken!",\n      "source": {\n        "pointer": "data/attributes/username"\n      }\n    }, {\n      "detail": "Doesn't look like a valid email.",\n      "source": {\n        "pointer": "data/attributes/email"\n      }\n    }\n  ]\n}
\n
\n
\n \n

The key detail provides a textual description of the problem.\nAlternatively, the key title can be used for the same purpose.

\n

The nested keys source.pointer detail which specific element\nof the request data was invalid.

\n

Note that JSON-API also allows for object-level errors to be placed\nin an object with pointer data, signifying that the problem\ncannot be traced to a specific attribute:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
{\n  "errors": [\n    {\n      "detail": "Some generic non property error message",\n      "source": {\n        "pointer": "data"\n      }\n    }\n  ]\n}
\n
\n
\n \n

When turn into a Errors object, you can read these errors\nthrough the property base:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{{#each @model.errors.base as |error|}}\n  <div class="error">\n    {{error.message}}\n  </div>\n{{/each}}
\n
\n
\n \n

Example of alternative implementation, overriding the default\nbehavior to deal with a different format of errors:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  extractErrors(store, typeClass, payload, id) {\n    if (payload && typeof payload === 'object' && payload._problems) {\n      payload = payload._problems;\n      this.normalizeErrors(typeClass, payload);\n    }\n    return payload;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "extractErrors", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "(String|Number)" + } + ], + "return": { + "description": "json The deserialized errors", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1491, + "description": "

keyForAttribute can be used to define rules for how to convert an\nattribute name in your model to a key in your JSON.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  keyForAttribute(attr, method) {\n    return underscore(attr).toUpperCase();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1518, + "description": "

keyForRelationship can be used to define a custom key when\nserializing and deserializing relationship properties. By default\nJSONSerializer does not provide an implementation of this method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\n\nexport default class PostSerializer extends JSONSerializer {\n  keyForRelationship(key, relationship, method) {\n    return `rel_${underscore(key)}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "typeClass", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1547, + "description": "

keyForLink can be used to define a custom key when deserializing link\nproperties.

\n", + "itemtype": "method", + "name": "keyForLink", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "kind", + "description": "`belongsTo` or `hasMany`", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 1563, + "itemtype": "method", + "name": "transformFor", + "access": "private", + "tagname": "", + "params": [ + { + "name": "attributeType", + "description": "", + "type": "String" + }, + { + "name": "skipAssertion", + "description": "", + "type": "Boolean" + } + ], + "return": { + "description": "transform", + "type": "Transform" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/index.js", + "line": 147, + "description": "

The normalizeResponse method is used to normalize a payload from the\nserver to a JSON-API Document.

\n

http://jsonapi.org/format/#document-structure

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
Serializer.extend({\n  normalizeResponse(store, primaryModelClass, payload, id, requestType) {\n    if (requestType === 'findRecord') {\n      return this.normalize(primaryModelClass, payload);\n    } else {\n      return payload.reduce(function(documentHash, item) {\n        let { data, included } = this.normalize(primaryModelClass, item);\n        documentHash.included.push(...included);\n        documentHash.data.push(data);\n        return documentHash;\n      }, { data: [], included: [] })\n    }\n  }\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 184, + "description": "

The serialize method is used when a record is saved in order to convert\nthe record into the form that your external data source expects.

\n

serialize takes an optional options hash with a single option:

\n\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n
Serializer.extend({\n  serialize(snapshot, options) {\n    let json = {\n      id: snapshot.id\n    };\n\n    snapshot.eachAttribute((key, attribute) => {\n      json[key] = snapshot.attr(key);\n    });\n\n    snapshot.eachRelationship((key, relationship) => {\n      if (relationship.kind === 'belongsTo') {\n        json[key] = snapshot.belongsTo(key, { id: true });\n      } else if (relationship.kind === 'hasMany') {\n        json[key] = snapshot.hasMany(key, { ids: true });\n      }\n    });\n\n    return json;\n  },\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object", + "optional": true + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 227, + "description": "

The normalize method is used to convert a payload received from your\nexternal data source into the normalized form store.push() expects. You\nshould override this method, munge the hash and return the normalized\npayload.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
Serializer.extend({\n  normalize(modelClass, resourceHash) {\n    let data = {\n      id:            resourceHash.id,\n      type:          modelClass.modelName,\n      attributes:    resourceHash\n    };\n    return { data: data };\n  }\n})
\n
\n
\n \n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "hash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "JSONSerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + } + ], + "events": [], + "properties": [ + { + "file": "../serializer/addon/json.js", + "line": 88, + "description": "

The primaryKey is used when serializing and deserializing\ndata. Ember Data always uses the id property to store the id of\nthe record. The external source may not always follow this\nconvention. In these cases it is useful to override the\nprimaryKey property to match the primaryKey of your external\nstore.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  primaryKey = '_id'\n}
\n
\n
\n \n", + "itemtype": "property", + "name": "primaryKey", + "type": "{String}", + "access": "public", + "tagname": "", + "default": "'id'", + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/json.js", + "line": 113, + "description": "

The attrs object can be used to declare a simple mapping between\nproperty names on Model records and payload keys in the\nserialized JSON object representing the record. An object with the\nproperty key can also be used to designate the attribute's key on\nthe response payload.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr } from '@ember-data/model';\n\nexport default class PersonModel extends Model {\n  @attr('string') firstName;\n  @attr('string') lastName;\n  @attr('string') occupation;\n  @attr('boolean') admin;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PersonSerializer extends JSONSerializer {\n  attrs = {\n    admin: 'is_admin',\n    occupation: { key: 'career' }\n  }\n}
\n
\n
\n \n

You can also remove attributes and relationships by setting the serialize\nkey to false in your mapping object.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  attrs = {\n    admin: { serialize: false },\n    occupation: { key: 'career' }\n  }\n}
\n
\n
\n \n

When serialized:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "firstName": "Harry",\n  "lastName": "Houdini",\n  "career": "magician"\n}
\n
\n
\n \n

Note that the admin is now not included in the payload.

\n

Setting serialize to true enforces serialization for hasMany\nrelationships even if it's neither a many-to-many nor many-to-none\nrelationship.

\n", + "itemtype": "property", + "name": "attrs", + "access": "public", + "tagname": "", + "type": "{Object}", + "class": "JSONSerializer", + "module": "@ember-data/serializer/json" + }, + { + "file": "../serializer/addon/index.js", + "line": 125, + "description": "

The store property is the application's store that contains\nall records. It can be used to look up serializers for other model\ntypes that may be nested inside the payload response.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
Serializer.extend({\n  extractRelationship(relationshipModelName, relationshipHash) {\n    let modelClass = this.store.modelFor(relationshipModelName);\n    let relationshipSerializer = this.store.serializerFor(relationshipModelName);\n    return relationshipSerializer.normalize(modelClass, relationshipHash);\n  }\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "store", + "type": "{Store}", + "access": "public", + "tagname": "", + "class": "JSONSerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Serializer", + "type": "class" + } + }, + "descendants": { + "data": [ + { + "type": "class", + "id": "ember-data-3.28.13-JSONAPISerializer" + }, + { + "type": "class", + "id": "ember-data-3.28.13-RESTSerializer" + } + ] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer/json", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-ManyArray-ced4bd0bfe.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-ManyArray-ced4bd0bfe.json new file mode 100644 index 000000000..e7c1b01c7 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-ManyArray-ced4bd0bfe.json @@ -0,0 +1,163 @@ +{ + "data": { + "id": "ember-data-3.28.13-ManyArray", + "type": "class", + "attributes": { + "name": "ManyArray", + "shortname": "ManyArray", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../model/addon/-private/system/many-array.js", + "line": 15, + "description": "

A ManyArray is a MutableArray that represents the contents of a has-many\nrelationship.

\n

The ManyArray is instantiated lazily the first time the relationship is\nrequested.

\n

This class is not intended to be directly instantiated by consuming applications.

\n

Inverses

\n

Often, the relationships in Ember Data applications will have\nan inverse. For example, imagine the following models are\ndefined:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany('comment') comments;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @belongsTo('post') post;\n}
\n
\n
\n \n

If you created a new instance of Post and added\na Comment record to its comments has-many\nrelationship, you would expect the comment's post\nproperty to be set to the post that contained\nthe has-many.

\n

We call the record to which a relationship belongs-to the\nrelationship's owner.

\n", + "access": "public", + "tagname": "", + "extends": "EmberObject", + "uses": [ + "DeprecatedEvented", + "Ember.MutableArray" + ], + "methods": [ + { + "file": "../model/addon/-private/system/many-array.js", + "line": 304, + "description": "

Reloads all of the records in the manyArray. If the manyArray\nholds a relationship that was originally fetched using a links url\nEmber Data will revisit the original links url to repopulate the\nrelationship.

\n

If the manyArray holds the result of a store.query() reload will\nre-run the original query.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
let user = store.peekRecord('user', '1')\nawait login(user);\n\nlet permissions = await user.permissions;\nawait permissions.reload();
\n
\n
\n \n", + "itemtype": "method", + "name": "reload", + "access": "public", + "tagname": "", + "class": "ManyArray", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/system/many-array.js", + "line": 331, + "description": "

Saves all of the records in the ManyArray.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
let inbox = await store.findRecord('inbox', '1');\nlet messages = await inbox.messages;\nmessages.forEach((message) => {\n  message.isRead = true;\n});\nmessages.save();
\n
\n
\n \n", + "itemtype": "method", + "name": "save", + "access": "public", + "tagname": "", + "return": { + "description": "promise", + "type": "PromiseArray" + }, + "class": "ManyArray", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/system/many-array.js", + "line": 362, + "description": "

Create a child record within the owner

\n", + "itemtype": "method", + "name": "createRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "hash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "record", + "type": "Model" + }, + "class": "ManyArray", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [ + { + "file": "../model/addon/-private/system/many-array.js", + "line": 67, + "description": "

The loading state of this array

\n", + "itemtype": "property", + "name": "isLoaded", + "type": "Boolean", + "access": "public", + "tagname": "", + "class": "ManyArray", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/system/many-array.js", + "line": 77, + "description": "

Metadata associated with the request for async hasMany relationships.

\n

Example

\n

Given that the server returns the following JSON payload when fetching a\nhasMany relationship:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
{\n  "comments": [{\n    "id": 1,\n    "comment": "This is the first comment",\n  }, {\n// ...\n  }],\n\n  "meta": {\n    "page": 1,\n    "total": 5\n  }\n}
\n
\n
\n \n

You can then access the meta data via the meta property:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
let comments = await post.comments;\nlet meta = comments.meta;\n\n// meta.page => 1\n// meta.total => 5
\n
\n
\n \n", + "itemtype": "property", + "name": "meta", + "type": "Object | null", + "access": "public", + "tagname": "", + "class": "ManyArray", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/system/many-array.js", + "line": 116, + "description": "

Retrieve the links for this relationship

\n", + "itemtype": "property", + "name": "links", + "type": "Object | null", + "access": "public", + "tagname": "", + "class": "ManyArray", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/system/many-array.js", + "line": 124, + "description": "

true if the relationship is polymorphic, false otherwise.

\n", + "itemtype": "property", + "name": "isPolymorphic", + "type": "Boolean", + "access": "private", + "tagname": "", + "class": "ManyArray", + "module": "@ember-data/store" + }, + { + "file": "../model/addon/-private/system/many-array.js", + "line": 132, + "description": "

The relationship which manages this array.

\n", + "itemtype": "property", + "name": "relationship", + "type": "ManyRelationship", + "access": "private", + "tagname": "", + "class": "ManyArray", + "module": "@ember-data/store" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "EmberObject", + "type": "missing" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-MinimumAdapterInterface-e647b24afc.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-MinimumAdapterInterface-e647b24afc.json new file mode 100644 index 000000000..e18fd0123 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-MinimumAdapterInterface-e647b24afc.json @@ -0,0 +1,600 @@ +{ + "data": { + "id": "ember-data-3.28.13-MinimumAdapterInterface", + "type": "class", + "attributes": { + "name": "MinimumAdapterInterface", + "shortname": "MinimumAdapterInterface", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter", + "namespace": "", + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 19, + "description": "

The following documentation describes the methods an\nadapter should implement with descriptions around when an\napplication might expect these methods to be called.

\n

Methods that are not required are marked as optional.

\n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 30, + "description": "

adapter.findRecord takes a request for a resource of a given type and id combination\nand should return a Promise which fulfills with data for a single resource matching that\ntype and id.

\n

The response will be fed to the associated serializer's normalizeResponse method with the\nrequestType set to findRecord, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing data for the record.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n

adapter.findRecord is called whenever the store needs to load, reload, or backgroundReload\nthe resource data for a given type and id.

\n", + "itemtype": "method", + "name": "findRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "a promise resolving with resource data to feed to the associated serializer", + "type": "Promise" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 59, + "description": "

adapter.findAll takes a request for resources of a given type and should return\n a Promise which fulfills with a collection of resource data matching that type.

\n

The response will be fed to the associated serializer's normalizeResponse method\n with the requestType set to findAll, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing records for type. Existing records for the type will not be removed.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n

adapter.findAll is called whenever store.findAll is asked to reload or backgroundReload.\nThe records in the response are merged with the contents of the store. Existing records for\nthe type will not be removed.

\n

See also shouldReloadAll and shouldBackgroundReloadAll

\n", + "itemtype": "method", + "name": "findAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "sinceToken", + "description": "This parameter is no longer used and will always be null.", + "type": "Null" + }, + { + "name": "snapshotRecordArray", + "description": "an object containing any passed in options,\n adapterOptions, and the ability to access a snapshot for each existing record of the type.", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "a promise resolving with resource data to feed to the associated serializer", + "type": "Promise" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 96, + "description": "

adapter.query takes a request for resources of a given type and should return\n a Promise which fulfills with a collection of resource data matching that type.

\n

The response will be fed to the associated serializer's normalizeResponse method\n with the requestType set to query, which should return a JSON:API document.

\n

As with findAll, the final result after normalization to JSON:API will be added to\nstore via store.push where it will merge with any existing records for type.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n

adapter.query is called whenever store.query is called or a previous query result is\nasked to reload.

\n

Existing records for the type will not be removed. The key difference is in the result\nreturned by the store. For findAll the result is all known records of the type,\nwhile for query it will only be the records returned from adapter.query.

\n", + "itemtype": "method", + "name": "query", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "recordArray", + "description": "", + "type": "AdapterPopulatedRecordArray" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "a promise resolving with resource data to feed to the associated serializer", + "type": "Promise" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 135, + "description": "

adapter.queryRecord takes a request for resource of a given type and should return\n a Promise which fulfills with data for a single resource matching that type.

\n

The response will be fed to the associated serializer's normalizeResponse method\n with the requestType set to queryRecord, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing data for the returned record.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n", + "itemtype": "method", + "name": "queryRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "query", + "description": "" + }, + { + "name": "options", + "description": "" + } + ], + "return": { + "description": "a promise resolving with resource data to feed to the associated serializer", + "type": "Promise" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 165, + "description": "

adapter.createRecord takes a request to create a resource of a given type and should\nreturn a Promise which fulfills with data for the newly created resource.

\n

The response will be fed to the associated serializer's normalizeResponse method\n with the requestType set to createRecord, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing data for the record.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n

If the adapter rejects or throws an error the record will enter an error state and the attributes\nthat had attempted to be saved will still be considered dirty.

\n

InvalidErrors

\n

When rejecting a createRecord request due to validation issues during save (typically a 422 status code),\nyou may throw an InvalidError.

\n

Throwing an InvalidError makes per-attribute errors available for records to use in the UI as needed.\nRecords can also use this information to mark themselves as being in an invalid state.\nFor more reading see the RecordData Errors RFC

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
let error = new Error(errorMessage);\n\n// these two properties combined\n// alert EmberData to this error being for\n// invalid properties on the record during\n// the request\nerror.isAdapterError = true;\nerror.code = 'InvalidError';\n\n// A JSON:API formatted array of errors\n// See https://jsonapi.org/format/#errors\nerror.errors = [];\n\nthrow error;
\n
\n
\n \n", + "itemtype": "method", + "name": "createRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "a promise resolving with resource data to feed to the associated serializer", + "type": "Promise" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 218, + "description": "

adapter.updateRecord takes a request to update a resource of a given type and should\nreturn a Promise which fulfills with the updated data for the resource.

\n

The response will be fed to the associated serializer's normalizeResponse method\n with the requestType set to updateRecord, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing data for the record.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n

If the adapter rejects or throws an error the record will enter an error state and the attributes\nthat had attempted to be saved will still be considered dirty.

\n

InvalidErrors

\n

When rejecting a createRecord request due to validation issues during save (typically a 422 status code),\nyou may throw an InvalidError.

\n

Throwing an InvalidError makes per-attribute errors available for records to use in the UI as needed.\nRecords can also use this information to mark themselves as being in an invalid state.\nFor more reading see the RecordData Errors RFC

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
let error = new Error(errorMessage);\n\n// these two properties combined\n// alert EmberData to this error being for\n// invalid properties on the record during\n// the request\nerror.isAdapterError = true;\nerror.code = 'InvalidError';\n\n// A JSON:API formatted array of errors\n// See https://jsonapi.org/format/#errors\nerror.errors = [];\n\nthrow error;
\n
\n
\n \n", + "itemtype": "method", + "name": "updateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 270, + "description": "

adapter.deleteRecord takes a request to delete a resource of a given type and\nshould return a Promise which resolves when that deletion is complete.

\n

Usually the response will be empty, but you may include additional updates in the\nresponse. The response will be fed to the associated serializer's normalizeResponse method\nwith the requestType set to deleteRecord, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing data.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n

If the adapter rejects or errors the record will need to be saved again once the reason\nfor the error is addressed in order to persist the deleted state.

\n", + "itemtype": "method", + "name": "deleteRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "snapshot", + "description": "A Snapshot containing the record's current data", + "type": "Snapshot" + } + ], + "return": { + "description": "" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 298, + "description": "

adapter.findBelongsTo takes a request to fetch a related resource located at a\nrelatedLink and should return a Promise which fulfills with data for a single\n resource.

\n

⚠️ This method is only called if the store previously received relationship information for a resource\ncontaining a related link.

\n

If the cache does not have a link for the relationship then findRecord will be used if a type and id\nfor the related resource is known.

\n

The response will be fed to the associated serializer's normalizeResponse method\n with the requestType set to findBelongsTo, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing data.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n", + "itemtype": "method", + "name": "findBelongsTo [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "snapshot", + "description": "A Snapshot containing the parent record's current data", + "type": "Snapshot" + }, + { + "name": "relatedLink", + "description": "The link at which the associated resource might be found", + "type": "String" + }, + { + "name": "relationship", + "description": "", + "type": "RelationshipSchema" + } + ], + "return": { + "description": "a promise resolving with resource data to feed to the associated serializer", + "type": "Promise" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 335, + "description": "

adapter.findHasMany takes a request to fetch a related resource collection located\n at a relatedLink and should return a Promise which fulfills with data for that\n collection.

\n

⚠️ This method is only called if the store previously received relationship information for a resource\ncontaining a related link.

\n

If the cache does not have a link for the relationship but the type and id of\nrelated resources are known then findRecord will be used for each individual related\nresource.

\n

The response will be fed to the associated serializer's normalizeResponse method\n with the requestType set to findHasMany, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing data.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n", + "itemtype": "method", + "name": "findhasMany [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "snapshot", + "description": "A Snapshot containing the parent record's current data", + "type": "Snapshot" + }, + { + "name": "relatedLink", + "description": "The link at which the associated resource collection might be found", + "type": "String" + }, + { + "name": "relationship", + "description": "", + "type": "RelationshipSchema" + } + ], + "return": { + "description": "a promise resolving with resource data to feed to the associated serializer", + "type": "Promise" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 373, + "description": "

⚠️ This Method is only called if coalesceFindRequests is true. The array passed to it is determined\nby the adapter's groupRecordsForFindMany method, and will be called once per group returned.

\n

adapter.findMany takes a request to fetch a collection of resources and should return a\nPromise which fulfills with data for that collection.

\n

The response will be fed to the associated serializer's normalizeResponse method\n with the requestType set to findMany, which should return a JSON:API document.

\n

The final result after normalization to JSON:API will be added to store via store.push where\nit will merge with any existing data.

\n

⚠️ If the adapter's response resolves to a false-y value, the associated serializer.normalizeResponse\ncall will NOT be made. In this scenario you may need to do at least a minimum amount of response\nprocessing within the adapter.

\n

See also groupRecordsForFindMany and coalesceFindRequests

\n", + "itemtype": "method", + "name": "findMany [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "ids", + "description": "An array of the ids of the resources to fetch", + "type": "Array" + }, + { + "name": "snapshots", + "description": "An array of snapshots of the available data for the resources to fetch", + "type": "Array" + } + ], + "return": { + "description": "a promise resolving with resource data to feed to the associated serializer", + "type": "Promise" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 404, + "description": "

This method provides the ability to generate an ID to assign to a new record whenever store.createRecord\nis called if no id was provided.

\n

Alternatively you can pass an id into the call to store.createRecord directly.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
let id = generateNewId(type);\nlet newRecord = store.createRecord(type, { id });
\n
\n
\n \n", + "itemtype": "method", + "name": "generateIdForRecord [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "type", + "description": "The type (or modelName) of record being created", + "type": "String" + }, + { + "name": "properties", + "description": "the properties passed as the second arg to `store.createRecord`" + } + ], + "return": { + "description": "a string ID that should be unique (no other models of `type` in the cache should have this `id`)", + "type": "String" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 444, + "description": "

⚠️ This Method is only called if coalesceFindRequests is true.

\n

This method allows for you to split pending requests for records into multiple findMany\nrequests. It receives an array of snapshots where each snapshot represents a unique record\nrequested via store.findRecord during the most recent runloop that was not found in the\ncache or needs to be reloaded. It should return an array of groups.

\n

A group is an array of snapshots meant to be fetched together by a single findMany request.

\n

By default if this method is not implemented EmberData will call findMany once with all\nrequested records as a single group when coalesceFindRequests is true.

\n

See also findMany and coalesceFindRequests

\n", + "itemtype": "method", + "name": "groupRecordsForFindMany [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "snapshots", + "description": "An array of snapshots", + "type": "Array" + } + ], + "return": { + "description": "An array of Snapshot arrays", + "type": "Array>" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 468, + "description": "

When a record is already available in the store and is requested again via store.findRecord,\nand reload is not specified as an option in the request, this method is called to determine\nwhether the record should be reloaded prior to returning the result.

\n

If reload is specified as an option in the request (true or false) this method will not\nbe called.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.findRecord('user', '1', { reload: false })
\n
\n
\n \n

The default behavior if this method is not implemented and the option is not specified is to\nnot reload, the same as a return of false.

\n

See also the documentation for shouldBackgroundReloadRecord which defaults to true.

\n", + "itemtype": "method", + "name": "shouldReloadRecord [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "snapshot", + "description": "A Snapshot containing the record's current data", + "type": "Snapshot" + } + ], + "return": { + "description": "true if the record should be reloaded immediately, false otherwise", + "type": "Boolean" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 494, + "description": "

When store.findAll(<type>) is called without a reload option, the adapter\nis presented the opportunity to trigger a new request for records of that type.

\n

If reload is specified as an option in the request (true or false) this method will not\nbe called.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.findAll('user', { reload: false })
\n
\n
\n \n

The default behavior if this method is not implemented and the option is not specified is to\nnot reload, the same as a return of false.

\n

Note: the Promise returned by store.findAll resolves to the same RecordArray instance\nreturned by store.peekAll for that type, and will include all records in the store for\nthe given type, including any previously existing records not returned by the reload request.

\n", + "itemtype": "method", + "name": "shouldReloadAll [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "snapshotArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "true if the a new request for all records of the type in SnapshotRecordArray should be made immediately, false otherwise", + "type": "Boolean" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 521, + "description": "

When a record is already available in the store and is requested again via store.findRecord,\nand the record does not need to be reloaded prior to return, this method provides the ability\nto specify whether a refresh of the data for the reload should be scheduled to occur in the background.

\n

Users may explicitly declare a record should/should not be background reloaded by passing\nbackgroundReload: true or backgroundReload: false as an option to the request respectively.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.findRecord('user', '1', { backgroundReload: false })
\n
\n
\n \n

If the backgroundReload option is not present, this method will be called to determine whether\na backgroundReload should be performed.

\n

The default behavior if this method is not implemented and the option was not specified is to\nbackground reload, the same as a return of true.

\n", + "itemtype": "method", + "name": "shouldBackgroundReloadRecord [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "snapshot", + "description": "A Snapshot containing the record's current data", + "type": "Snapshot" + } + ], + "return": { + "description": "true if the record should be reloaded in the background, false otherwise", + "type": "Boolean" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 548, + "description": "

When store.findAll(<type>) is called and a reload is not initiated, the adapter\nis presented the opportunity to trigger a new non-blocking (background) request for\nrecords of that type

\n

Users may explicitly declare that this background request should/should not occur by passing\nbackgroundReload: true or backgroundReload: false as an option to the request respectively.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.findAll('user', { backgroundReload: false })
\n
\n
\n \n

The default behavior if this method is not implemented and the option is not specified is to\nperform a reload, the same as a return of true.

\n", + "itemtype": "method", + "name": "shouldBackgroundReloadAll [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "snapshotArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "true if the a new request for all records of the type in SnapshotRecordArray should be made in the background, false otherwise", + "type": "Boolean" + }, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 572, + "description": "

In some situations the adapter may need to perform cleanup when destroyed,\nthat cleanup can be done in destroy.

\n

If not implemented, the store does not inform the adapter of destruction.

\n", + "itemtype": "method", + "name": "destroy [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + } + ], + "events": [], + "properties": [ + { + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 425, + "description": "

If your adapter implements findMany, setting this to true will cause findRecord\nrequests triggered within the same runloop to be coalesced into one or more calls\nto adapter.findMany. The number of calls made and the records contained in each call\ncan be tuned by your adapter's groupRecordsForHasMany method.

\n

Implementing coalescing using this flag and the associated methods does not always offer\nthe right level of correctness, timing control or granularity. If your application would\nbe better suited coalescing across multiple types, coalescing for longer than a single runloop,\nor with a more custom request structure, coalescing within your application adapter may prove\nmore effective.

\n", + "itemtype": "property", + "name": "coalesceFindRequests [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "type": "{boolean} true if the requests to find individual records should be coalesced, false otherwise", + "class": "MinimumAdapterInterface", + "module": "@ember-data/adapter" + } + ] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-MinimumSerializerInterface-31366d5385.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-MinimumSerializerInterface-31366d5385.json new file mode 100644 index 000000000..baa41989e --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-MinimumSerializerInterface-31366d5385.json @@ -0,0 +1,211 @@ +{ + "data": { + "id": "ember-data-3.28.13-MinimumSerializerInterface", + "type": "class", + "attributes": { + "name": "MinimumSerializerInterface", + "shortname": "MinimumSerializerInterface", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer", + "namespace": "", + "file": "../store/addon/-private/ts-interfaces/minimum-serializer-interface.ts", + "line": 15, + "description": "

The following documentation describes the methods an application\nserializer should implement with descriptions around when an\napplication might expect these methods to be called.

\n

Methods that are not required are marked as optional.

\n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../store/addon/-private/ts-interfaces/minimum-serializer-interface.ts", + "line": 26, + "description": "

This method is responsible for normalizing the value resolved from the promise returned\nby an Adapter request into the format expected by the Store.

\n

The output should be a JSON:API Document\nwith the following additional restrictions:

\n
    \n
  • type should be formatted in the singular dasherized lowercase form
  • \n
  • members (the property names of attributes and relationships) should be formatted\n to match their definition in the corresponding Model definition. Typically this\n will be camelCase.
  • \n
  • lid is\n a valid optional sibling to id and type in both Resources\n and Resource Identifier Objects
  • \n
\n", + "itemtype": "method", + "name": "normalizeResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "rawPayload", + "description": "The raw JSON response data returned from an API request.\n This correlates to the value the promise returned by the adapter method that performed\n the request resolved to.", + "type": "JSONObject" + }, + { + "name": "id", + "description": "For a findRecord request, this is the id initially provided\n in the call to store.findRecord. Else this value is null.", + "type": "String|null" + }, + { + "name": "requestType", + "description": "The\n type of request the Adapter had been asked to perform.", + "type": "'findRecord' | 'queryRecord' | 'findAll' | 'findBelongsTo' | 'findHasMany' | 'findMany' | 'query' | 'createRecord' | 'deleteRecord' | 'updateRecord'" + } + ], + "return": { + "description": "a document following the structure of a JSON:API Document.", + "type": "JsonApiDocument" + }, + "class": "MinimumSerializerInterface", + "module": "@ember-data/serializer" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-serializer-interface.ts", + "line": 74, + "description": "

This method is responsible for serializing an individual record\nvia a Snapshot into the format expected by the API.

\n

This method is called by snapshot.serialize().

\n

When using Model, this method is called by record.serialize().

\n

When using JSONAPIAdapter or RESTAdapter this method is called\nby updateRecord and createRecord if Serializer.serializeIntoHash\nis not implemented.

\n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "A Snapshot for the record to serialize", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object", + "optional": true + } + ], + "class": "MinimumSerializerInterface", + "module": "@ember-data/serializer" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-serializer-interface.ts", + "line": 93, + "description": "

This method is intended to normalize data into a JSON:API Document\nwith a data member containing a single Resource.

\n
    \n
  • type should be formatted in the singular, dasherized and lowercase form
  • \n
  • members (the property names of attributes and relationships) should be formatted\n to match their definition in the corresponding Model definition. Typically this\n will be camelCase.
  • \n
  • lid is\n a valid optional sibling to id and type in both Resources\n and Resource Identifier Objects
  • \n
\n

This method is called by the Store when store.normalize(modelName, payload) is\ncalled. It is recommended to use store.serializerFor(modelName).normalizeResponse\nover store.normalize.

\n

This method may be called when also using the RESTSerializer\nwhen serializer.pushPayload is called by store.pushPayload.\nHowever, it is recommended to use store.push over store.pushPayload after normalizing\nthe payload directly.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
function pushPayload(store, modelName, rawPayload) {\n  const ModelClass = store.modelFor(modelName);\n  const serializer = store.serializerFor(modelName);\n  const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query');\n\n  return store.push(jsonApiPayload);\n}
\n
\n
\n \n

This method may be called when also using the JSONAPISerializer\nwhen normalizing included records. If mixing serializer usage in this way\nwe recommend implementing this method, but caution that it may lead\nto unexpected mixing of formats.

\n

This method may also be called when normalizing embedded relationships when\nusing the EmbeddedRecordsMixin. If using this mixin in a serializer in\nyour application we recommend implementing this method, but caution that\nit may lead to unexpected mixing of formats.

\n", + "itemtype": "method", + "name": "normalize [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "rawPayload", + "description": "Some raw JSON data to be normalized into a JSON:API Resource.", + "type": "JSONObject" + }, + { + "name": "prop", + "description": "When called by the EmbeddedRecordsMixin this param will be the\n property at which the object provided as rawPayload was found.", + "type": "String", + "optional": true + } + ], + "return": { + "description": "A JSON:API Document\n containing a single JSON:API Resource\n as its primary data.", + "type": "SingleResourceDocument" + }, + "class": "MinimumSerializerInterface", + "module": "@ember-data/serializer" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-serializer-interface.ts", + "line": 149, + "description": "

When using JSONAPIAdapter or RESTAdapter this method is called\nby adapter.updateRecord and adapter.createRecord if serializer.serializeIntoHash\nis implemented. If this method is not implemented, serializer.serialize\nwill be called in this case.

\n

You can use this method to customize the root keys serialized into the payload.\nThe hash property should be modified by reference.

\n

For instance, your API may expect resources to be keyed by underscored type in the payload:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
{\n  _user: {\n    type: 'user',\n    id: '1'\n  }\n}
\n
\n
\n \n

Which when using these adapters can be achieved by implementing this method similar\nto the following:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
serializeIntoHash(hash, ModelClass, snapshot, options) {\n  hash[`_${snapshot.modelName}`] = this.serialize(snapshot, options).data;\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeIntoHash [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "hash", + "description": "A top most object of the request payload onto\n which to append the serialized record" + }, + { + "name": "schema", + "description": "An object with methods for accessing information about\n the type, attributes and relationships of the primary type associated with the request.", + "type": "ModelSchema" + }, + { + "name": "snapshot", + "description": "A Snapshot for the record to serialize", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "optional": true + } + ], + "return": { + "description": "", + "type": "Void" + }, + "class": "MinimumSerializerInterface", + "module": "@ember-data/serializer" + }, + { + "file": "../store/addon/-private/ts-interfaces/minimum-serializer-interface.ts", + "line": 191, + "description": "

This method allows for normalization of data when store.pushPayload is called\nand should be implemented if you want to use that method.

\n

The method is responsible for pushing new data to the store using store.push\nonce any necessary normalization has occurred, and no data in the store will be\nupdated unless it does so.

\n

The normalized form pushed to the store should be a JSON:API Document\nwith the following additional restrictions:

\n
    \n
  • type should be formatted in the singular, dasherized and lowercase form
  • \n
  • members (the property names of attributes and relationships) should be formatted\n to match their definition in the corresponding Model definition. Typically this\n will be camelCase.
  • \n
  • lid is\n a valid optional sibling to id and type in both Resources\n and Resource Identifier Objects
  • \n
\n

If you need better control over normalization or want access to the records being added or updated\nin the store, we recommended using store.push over store.pushPayload after normalizing\nthe payload directly. This can even take advantage of an existing serializer for the format\nthe data is in, for example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
function pushPayload(store, modelName, rawPayload) {\n  const ModelClass = store.modelFor(modelName);\n  const serializer = store.serializerFor(modelName);\n  const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query');\n\n  return store.push(jsonApiPayload);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "pushPayload [OPTIONAL]", + "access": "public", + "tagname": "", + "optional": 1, + "params": [ + { + "name": "store", + "description": "The store service that initiated the request being normalized", + "type": "Store" + }, + { + "name": "rawPayload", + "description": "The raw JSON response data returned from an API request.\n This JSON should be in the API format expected by the serializer.", + "type": "JSONObject" + } + ], + "return": { + "description": "", + "type": "Void" + }, + "class": "MinimumSerializerInterface", + "module": "@ember-data/serializer" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Model-484bf6ed29.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Model-484bf6ed29.json new file mode 100644 index 000000000..ba87d6ff2 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Model-484bf6ed29.json @@ -0,0 +1,972 @@ +{ + "data": { + "id": "ember-data-3.28.13-Model", + "type": "class", + "attributes": { + "name": "Model", + "shortname": "Model", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/model", + "namespace": "", + "file": "../model/addon/-private/model.js", + "line": 105, + "description": "

Base class from which Models can be define.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
import Model, { attr } from '@ember-data/model';\n\nexport default class User extends Model {\n  @attr name;\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "EmberObject", + "uses": [ + "EmberData.DeprecatedEvented" + ], + "methods": [ + { + "file": "../model/addon/-private/model.js", + "line": 615, + "description": "

Create a JSON representation of the record, using the serialization\nstrategy of the store's adapter.

\n

serialize takes an optional hash as a parameter, currently\nsupported options are:

\n
    \n
  • includeId: true if the record's ID should be included in the\n JSON representation.
  • \n
\n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "an object whose values are primitive JSON values only", + "type": "Object" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 699, + "deprecated": true, + "itemtype": "method", + "name": "send", + "access": "private", + "tagname": "", + "params": [ + { + "name": "name", + "description": "", + "type": "String" + }, + { + "name": "context", + "description": "", + "type": "Object" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 710, + "deprecated": true, + "itemtype": "method", + "name": "transitionTo", + "access": "private", + "tagname": "", + "params": [ + { + "name": "name", + "description": "", + "type": "String" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 736, + "description": "

Marks the record as deleted but does not save it. You must call\nsave afterwards if you want to persist it. You might use this\nmethod if you want to allow the user to still rollbackAttributes()\nafter a delete was made.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/controllers/model/delete.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n
import Controller from '@ember/controller';\nimport { action } from '@ember/object';\n\nexport default class ModelDeleteController extends Controller {\n  @action\n  softDelete() {\n    this.model.deleteRecord();\n  }\n\n  @action\n  confirm() {\n    this.model.save();\n  }\n\n  @action\n  undo() {\n    this.model.rollbackAttributes();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deleteRecord", + "access": "public", + "tagname": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 777, + "description": "

Same as deleteRecord, but saves the record immediately.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/controllers/model/delete.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import Controller from '@ember/controller';\nimport { action } from '@ember/object';\n\nexport default class ModelDeleteController extends Controller {\n  @action\n  delete() {\n    this.model.destroyRecord().then(function() {\n      this.transitionToRoute('model.index');\n    });\n  }\n}
\n
\n
\n \n

If you pass an object on the adapterOptions property of the options\nargument it will be passed to your adapter via the snapshot

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
record.destroyRecord({ adapterOptions: { subscribe: false } });
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import MyCustomAdapter from './custom-adapter';\n\nexport default class PostAdapter extends MyCustomAdapter {\n  deleteRecord(store, type, snapshot) {\n    if (snapshot.adapterOptions.subscribe) {\n      // ...\n    }\n    // ...\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "destroyRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "a promise that will be resolved when the adapter returns\nsuccessfully or rejected if the adapter returns with an error.", + "type": "Promise" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 832, + "description": "

Unloads the record from the store. This will not send a delete request\nto your server, it just unloads the record from memory.

\n", + "itemtype": "method", + "name": "unloadRecord", + "access": "public", + "tagname": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 850, + "itemtype": "method", + "name": "_notifyProperties", + "access": "private", + "tagname": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 867, + "description": "

Returns an object, whose keys are changed properties, and value is\nan [oldProp, newProp] array.

\n

The array represents the diff of the canonical state with the local state\nof the model. Note: if the model is created locally, the canonical state is\nempty since the adapter hasn't acknowledged the attributes yet:

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/mascot.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import Model, { attr } from '@ember-data/model';\n\nexport default class MascotModel extends Model {\n  @attr('string') name;\n  @attr('boolean', {\n    defaultValue: false\n  })\n  isAdmin;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n
let mascot = store.createRecord('mascot');\n\nmascot.changedAttributes(); // {}\n\nmascot.set('name', 'Tomster');\nmascot.changedAttributes(); // { name: [undefined, 'Tomster'] }\n\nmascot.set('isAdmin', true);\nmascot.changedAttributes(); // { isAdmin: [undefined, true], name: [undefined, 'Tomster'] }\n\nmascot.save().then(function() {\n  mascot.changedAttributes(); // {}\n\n  mascot.set('isAdmin', false);\n  mascot.changedAttributes(); // { isAdmin: [true, false] }\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "changedAttributes", + "access": "public", + "tagname": "", + "return": { + "description": "an object, whose keys are changed properties,\n and value is an [oldProp, newProp] array.", + "type": "Object" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 917, + "description": "

If the model hasDirtyAttributes this function will discard any unsaved\nchanges. If the model isNew it will be removed from the store.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
record.get('name'); // 'Untitled Document'\nrecord.set('name', 'Doc 1');\nrecord.get('name'); // 'Doc 1'\nrecord.rollbackAttributes();\nrecord.get('name'); // 'Untitled Document'
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "rollbackAttributes", + "access": "public", + "tagname": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 942, + "itemtype": "method", + "name": "_createSnapshot", + "access": "private", + "tagname": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 957, + "description": "

Save the record and persist any changes to the record to an\nexternal source via the adapter.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
record.set('name', 'Tomster');\nrecord.save().then(function() {\n  // Success callback\n}, function() {\n  // Error callback\n});
\n
\n
\n \n

If you pass an object using the adapterOptions property of the options\n argument it will be passed to your adapter via the snapshot.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
record.save({ adapterOptions: { subscribe: false } });
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import MyCustomAdapter from './custom-adapter';\n\nexport default class PostAdapter extends MyCustomAdapter {\n  updateRecord(store, type, snapshot) {\n    if (snapshot.adapterOptions.subscribe) {\n      // ...\n    }\n    // ...\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "save", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "a promise that will be resolved when the adapter returns\nsuccessfully or rejected if the adapter returns with an error.", + "type": "Promise" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1004, + "description": "

Reload the record from the adapter.

\n

This will only work if the record has already finished loading.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/controllers/model/view.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import Controller from '@ember/controller';\nimport { action } from '@ember/object';\n\nexport default class ViewController extends Controller {\n  @action\n  reload() {\n    this.model.reload().then(function(model) {\n    // do something with the reloaded model\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "reload", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "optional, may include `adapterOptions` hash which will be passed to adapter request", + "type": "Object" + } + ], + "return": { + "description": "a promise that will be resolved with the record when the\nadapter returns successfully or rejected if the adapter returns\nwith an error.", + "type": "Promise" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1060, + "description": "

Get the reference for the specified belongsTo relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/blog.js
1\n2\n3\n4\n5\n
import Model, { belongsTo } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n  @belongsTo({ async: true }) user;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n
let blog = store.push({\n  data: {\n    type: 'blog',\n    id: 1,\n    relationships: {\n      user: {\n        data: { type: 'user', id: 1 }\n      }\n    }\n  }\n});\nlet userRef = blog.belongsTo('user');\n\n// check if the user relationship is loaded\nlet isLoaded = userRef.value() !== null;\n\n// get the record of the reference (null if not yet available)\nlet user = userRef.value();\n\n// get the identifier of the reference\nif (userRef.remoteType() === "id") {\n  let id = userRef.id();\n} else if (userRef.remoteType() === "link") {\n  let link = userRef.link();\n}\n\n// load user (via store.findRecord or store.findBelongsTo)\nuserRef.load().then(...)\n\n// or trigger a reload\nuserRef.reload().then(...)\n\n// provide data for reference\nuserRef.push({\n  type: 'user',\n  id: 1,\n  attributes: {\n    username: "@user"\n  }\n}).then(function(user) {\n  userRef.value() === user;\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "belongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "name", + "description": "of the relationship", + "type": "String" + } + ], + "since": "2.5.0", + "return": { + "description": "reference for this relationship", + "type": "BelongsToReference" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1128, + "description": "

Get the reference for the specified hasMany relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/blog.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n  @hasMany({ async: true }) comments;\n}\n\nlet blog = store.push({\n  data: {\n    type: 'blog',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [\n          { type: 'comment', id: 1 },\n          { type: 'comment', id: 2 }\n        ]\n      }\n    }\n  }\n});\nlet commentsRef = blog.hasMany('comments');\n\n// check if the comments are loaded already\nlet isLoaded = commentsRef.value() !== null;\n\n// get the records of the reference (null if not yet available)\nlet comments = commentsRef.value();\n\n// get the identifier of the reference\nif (commentsRef.remoteType() === "ids") {\n  let ids = commentsRef.ids();\n} else if (commentsRef.remoteType() === "link") {\n  let link = commentsRef.link();\n}\n\n// load comments (via store.findMany or store.findHasMany)\ncommentsRef.load().then(...)\n\n// or trigger a reload\ncommentsRef.reload().then(...)\n\n// provide data for reference\ncommentsRef.push([{ type: 'comment', id: 1 }, { type: 'comment', id: 2 }]).then(function(comments) {\n  commentsRef.value() === comments;\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "hasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "name", + "description": "of the relationship", + "type": "String" + } + ], + "since": "2.5.0", + "return": { + "description": "reference for this relationship", + "type": "HasManyReference" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1191, + "description": "

Given a callback, iterates over each of the relationships in the model,\ninvoking the callback with the name of each relationship and its relationship\ndescriptor.

\n

The callback method you provide should have the following signature (all\nparameters are optional):

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
function(name, descriptor);
\n
\n
\n \n
    \n
  • name the name of the current property in the iteration
  • \n
  • descriptor the meta object that describes this relationship
  • \n
\n

The relationship descriptor argument is an object with the following properties.

\n
    \n
  • key String the name of this relationship on the Model
  • \n
  • kind String "hasMany" or "belongsTo"
  • \n
  • options Object the original options hash passed when the relationship was declared
  • \n
  • parentType Model the type of the Model that owns this relationship
  • \n
  • type String the type name of the related Model
  • \n
\n

Note that in addition to a callback, you can also pass an optional target\nobject that will be set as this on the context.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n   serialize(record, options) {\n   let json = {};\n\n   record.eachRelationship(function(name, descriptor) {\n     if (descriptor.kind === 'hasMany') {\n       let serializedHasManyName = name.toUpperCase() + '_IDS';\n       json[serializedHasManyName] = record.get(name).mapBy('id');\n     }\n   });\n\n   return json;\n }\n  }
\n
\n
\n \n", + "itemtype": "method", + "name": "eachRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "the callback to invoke", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Any" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1262, + "description": "

Create should only ever be called by the store. To create an instance of a\nModel in a dirty state use store.createRecord.

\n

To create instances of Model in a clean state, use store.push

\n", + "itemtype": "method", + "name": "create", + "access": "private", + "tagname": "", + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1323, + "description": "

For a given relationship name, returns the model type of the relationship.

\n

For example, if you define a model like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @hasMany('comment') comments;\n}
\n
\n
\n \n

Calling store.modelFor('post').typeForRelationship('comments', store) will return Comment.

\n", + "itemtype": "method", + "name": "typeForRelationship", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "name", + "description": "the name of the relationship", + "type": "String" + }, + { + "name": "store", + "description": "an instance of Store", + "type": "Store" + } + ], + "return": { + "description": "the type of the relationship, or undefined", + "type": "Model" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1355, + "description": "

Find the relationship which is the inverse of the one asked for.

\n

For example, if you define models like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n   @hasMany('message') comments;\n }
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/message.js
1\n2\n3\n4\n5\n6\n
import Model from '@ember-data/model';\nimport { belongsTo } from '@ember-decorators/data';\n\nexport default class MessageModel extends Model {\n   @belongsTo('post') owner;\n }
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.modelFor('post').inverseFor('comments', store) // { type: App.Message, name: 'owner', kind: 'belongsTo' }\nstore.modelFor('message').inverseFor('owner', store) // { type: App.Post, name: 'comments', kind: 'hasMany' }
\n
\n
\n \n", + "itemtype": "method", + "name": "inverseFor", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "name", + "description": "the name of the relationship", + "type": "String" + }, + { + "name": "store", + "description": "", + "type": "Store" + } + ], + "return": { + "description": "the inverse relationship, or null", + "type": "Object" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1795, + "description": "

Given a callback, iterates over each of the relationships in the model,\ninvoking the callback with the name of each relationship and its relationship\ndescriptor.

\n", + "itemtype": "method", + "name": "eachRelationship", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "callback", + "description": "the callback to invoke", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Any" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1812, + "description": "

Given a callback, iterates over each of the types related to a model,\ninvoking the callback with the related type's class. Each type will be\nreturned just once, regardless of how many different relationships it has\nwith a model.

\n", + "itemtype": "method", + "name": "eachRelatedType", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "callback", + "description": "the callback to invoke", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Any" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1965, + "description": "

Iterates through the attributes of the model, calling the passed function on each\nattribute.

\n

The callback method you provide should have the following signature (all\nparameters are optional):

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
function(name, meta);
\n
\n
\n \n
    \n
  • name the name of the current property in the iteration
  • \n
  • meta the meta object for the attribute property in the iteration
  • \n
\n

Note that in addition to a callback, you can also pass an optional target\nobject that will be set as this on the context.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n
import Model, { attr } from '@ember-data/model';\n\nclass PersonModel extends Model {\n   @attr('string') firstName;\n   @attr('string') lastName;\n   @attr('date') birthday;\n }\n\nPersonModel.eachAttribute(function(name, meta) {\n   console.log(name, meta);\n });\n\n// prints:\n// firstName {type: "string", isAttribute: true, options: Object, parentType: function, name: "firstName"}\n// lastName {type: "string", isAttribute: true, options: Object, parentType: function, name: "lastName"}\n// birthday {type: "date", isAttribute: true, options: Object, parentType: function, name: "birthday"}
\n
\n
\n \n", + "itemtype": "method", + "name": "eachAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "The callback to execute", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Object", + "optional": true + } + ], + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2015, + "description": "

Iterates through the transformedAttributes of the model, calling\nthe passed function on each attribute. Note the callback will not be\ncalled for any attributes that do not have an transformation type.

\n

The callback method you provide should have the following signature (all\nparameters are optional):

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
function(name, type);
\n
\n
\n \n
    \n
  • name the name of the current property in the iteration
  • \n
  • type a string containing the name of the type of transformed\napplied to the attribute
  • \n
\n

Note that in addition to a callback, you can also pass an optional target\nobject that will be set as this on the context.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Model, { attr } from '@ember-data/model';\n\nlet Person = Model.extend({\n   firstName: attr(),\n   lastName: attr('string'),\n   birthday: attr('date')\n });\n\nPerson.eachTransformedAttribute(function(name, type) {\n   console.log(name, type);\n });\n\n// prints:\n// lastName string\n// birthday date
\n
\n
\n \n", + "itemtype": "method", + "name": "eachTransformedAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "The callback to execute", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Object", + "optional": true + } + ], + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2066, + "description": "

Returns the name of the model class.

\n", + "itemtype": "method", + "name": "toString", + "access": "public", + "tagname": "", + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2085, + "description": "

Provides info about the model for debugging purposes\nby grouping the properties into more semantic groups.

\n

Meant to be used by debugging tools such as the Chrome Ember Extension.

\n
    \n
  • Groups all attributes in "Attributes" group.
  • \n
  • Groups all belongsTo relationships in "Belongs To" group.
  • \n
  • Groups all hasMany relationships in "Has Many" group.
  • \n
  • Groups all flags in "Flags" group.
  • \n
  • Flags relationship CPs as expensive properties.
  • \n
\n", + "itemtype": "method", + "name": "_debugInfo", + "access": "private", + "tagname": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2149, + "description": "

Override the default event firing from Ember.Evented to\nalso call methods with the given name.

\n", + "itemtype": "method", + "name": "trigger", + "access": "private", + "tagname": "", + "params": [ + { + "name": "name", + "description": "", + "type": "String" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2181, + "description": "

Use JSONSerializer to\nget the JSON representation of a record.

\n

toJSON takes an optional hash as a parameter, currently\nsupported options are:

\n
    \n
  • includeId: true if the record's ID should be included in the\nJSON representation.
  • \n
\n", + "itemtype": "method", + "name": "toJSON", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "A JSON representation of the object.", + "type": "Object" + }, + "class": "Model", + "module": "@ember-data/model" + } + ], + "events": [ + { + "file": "../model/addon/-private/model.js", + "line": 634, + "description": "

Fired when the record is ready to be interacted with,\nthat is either loaded from the server or created locally.

\n", + "deprecated": true, + "access": "public", + "tagname": "", + "itemtype": "event", + "name": "ready", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 643, + "description": "

Fired when the record is loaded from the server.

\n", + "deprecated": true, + "access": "public", + "tagname": "", + "itemtype": "event", + "name": "didLoad", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 651, + "description": "

Fired when the record is updated.

\n", + "deprecated": true, + "access": "public", + "tagname": "", + "itemtype": "event", + "name": "didUpdate", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 659, + "description": "

Fired when a new record is commited to the server.

\n", + "deprecated": true, + "access": "public", + "tagname": "", + "itemtype": "event", + "name": "didCreate", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 667, + "description": "

Fired when the record is deleted.

\n", + "deprecated": true, + "access": "public", + "tagname": "", + "itemtype": "event", + "name": "didDelete", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 675, + "description": "

Fired when the record becomes invalid.

\n", + "deprecated": true, + "access": "public", + "tagname": "", + "itemtype": "event", + "name": "becameInvalid", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 683, + "description": "

Fired when the record enters the error state.

\n", + "deprecated": true, + "access": "public", + "tagname": "", + "itemtype": "event", + "name": "becameError", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 691, + "description": "

Fired when the record is rolled back.

\n", + "deprecated": true, + "access": "public", + "tagname": "", + "itemtype": "event", + "name": "rolledBack", + "class": "Model", + "module": "@ember-data/model" + } + ], + "properties": [ + { + "file": "../model/addon/-private/model.js", + "line": 141, + "description": "

If this property is true the record is in the empty\nstate. Empty is the first state all records enter after they have\nbeen created. Most records created by the store will quickly\ntransition to the loading state if data needs to be fetched from\nthe server or the created state if the record is created on the\nclient. A record can also enter the empty state if the adapter is\nunable to locate the record.

\n", + "itemtype": "property", + "name": "isEmpty", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 160, + "description": "

If this property is true the record is in the loading state. A\nrecord enters this state when the store asks the adapter for its\ndata. It remains in this state until the adapter provides the\nrequested data.

\n", + "itemtype": "property", + "name": "isLoading", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 176, + "description": "

If this property is true the record is in the loaded state. A\nrecord enters this state when its data is populated. Most of a\nrecord's lifecycle is spent inside substates of the loaded\nstate.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
let record = store.createRecord('model');\nrecord.get('isLoaded'); // true\n\nstore.findRecord('model', 1).then(function(model) {\n  model.get('isLoaded'); // true\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "isLoaded", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 203, + "description": "

If this property is true the record is in the dirty state. The\nrecord has local changes that have not yet been saved by the\nadapter. This includes records that have been created (but not yet\nsaved) or deleted.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
let record = store.createRecord('model');\nrecord.get('hasDirtyAttributes'); // true\n\nstore.findRecord('model', 1).then(function(model) {\n  model.get('hasDirtyAttributes'); // false\n  model.set('foo', 'some value');\n  model.get('hasDirtyAttributes'); // true\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "property", + "name": "hasDirtyAttributes", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 233, + "description": "

If this property is true the record is in the saving state. A\nrecord enters the saving state when save is called, but the\nadapter has not yet acknowledged that the changes have been\npersisted to the backend.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
let record = store.createRecord('model');\nrecord.get('isSaving'); // false\nlet promise = record.save();\nrecord.get('isSaving'); // true\npromise.then(function() {\n  record.get('isSaving'); // false\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "isSaving", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 261, + "description": "

If this property is true the record is in the deleted state\nand has been marked for deletion. When isDeleted is true and\nhasDirtyAttributes is true, the record is deleted locally but the deletion\nwas not yet persisted. When isSaving is true, the change is\nin-flight. When both hasDirtyAttributes and isSaving are false, the\nchange has persisted.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n
let record = store.createRecord('model');\nrecord.get('isDeleted');    // false\nrecord.deleteRecord();\n\n// Locally deleted\nrecord.get('isDeleted');           // true\nrecord.get('hasDirtyAttributes');  // true\nrecord.get('isSaving');            // false\n\n// Persisting the deletion\nlet promise = record.save();\nrecord.get('isDeleted');    // true\nrecord.get('isSaving');     // true\n\n// Deletion Persisted\npromise.then(function() {\n  record.get('isDeleted');          // true\n  record.get('isSaving');           // false\n  record.get('hasDirtyAttributes'); // false\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "isDeleted", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 304, + "description": "

If this property is true the record is in the new state. A\nrecord will be in the new state when it has been created on the\nclient and the adapter has not yet report that it was successfully\nsaved.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
let record = store.createRecord('model');\nrecord.get('isNew'); // true\n\nrecord.save().then(function(model) {\n  model.get('isNew'); // false\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "isNew", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 331, + "description": "

If this property is true the record is in the valid state.

\n

A record will be in the valid state when the adapter did not report any\nserver-side validation failures.

\n", + "itemtype": "property", + "name": "isValid", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 347, + "description": "

If the record is in the dirty state this property will report what\nkind of change has caused it to move into the dirty\nstate. Possible values are:

\n
    \n
  • created The record has been created by the client and not yet saved to the adapter.
  • \n
  • updated The record has been updated by the client and not yet saved to the adapter.
  • \n
  • deleted The record has been deleted by the client and not yet saved to the adapter.
  • \n
\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
let record = store.createRecord('model');\nrecord.get('dirtyType'); // 'created'
\n
\n
\n \n", + "itemtype": "property", + "name": "dirtyType", + "access": "public", + "tagname": "", + "type": "{String}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 373, + "description": "

If true the adapter reported that it was unable to save local\nchanges to the backend for any reason other than a server-side\nvalidation error.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
record.get('isError'); // false\nrecord.set('foo', 'valid value');\nrecord.save().then(null, function() {\n  record.get('isError'); // true\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "isError", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 411, + "description": "

If true the store is attempting to reload the record from the adapter.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
record.get('isReloading'); // false\nrecord.reload();\nrecord.get('isReloading'); // true
\n
\n
\n \n", + "itemtype": "property", + "name": "isReloading", + "access": "public", + "tagname": "", + "type": "{Boolean}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 429, + "description": "

All ember models have an id property. This is an identifier\nmanaged by an external source. These are always coerced to be\nstrings before being used internally. Note when declaring the\nattributes for a model it is an error to declare an id\nattribute.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
let record = store.createRecord('model');\nrecord.get('id'); // null\n\nstore.findRecord('model', 1).then(function(model) {\n  model.get('id'); // '1'\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "id", + "access": "public", + "tagname": "", + "type": "{String}", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 469, + "itemtype": "property", + "name": "currentState", + "access": "private", + "tagname": "", + "type": "{Object}", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 491, + "itemtype": "property", + "name": "_internalModel", + "access": "private", + "tagname": "", + "type": "{Object}", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 497, + "description": "

The store service instance which created this record instance

\n", + "itemtype": "property", + "name": "store", + "access": "public", + "tagname": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 504, + "description": "

When the record is in the invalid state this object will contain\nany errors returned by the adapter. When present the errors hash\ncontains keys corresponding to the invalid property names\nand values which are arrays of Javascript objects with two keys:

\n
    \n
  • message A string containing the error message from the backend
  • \n
  • attribute The name of the property associated with this error message
  • \n
\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
record.get('errors.length'); // 0\nrecord.set('foo', 'invalid value');\nrecord.save().catch(function() {\n  record.get('errors').get('foo');\n  // [{message: 'foo should be a number.', attribute: 'foo'}]\n});
\n
\n
\n \n

The errors property is useful for displaying error messages to\nthe user.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
<label>Username: <Input @value={{@model.username}} /> </label>\n{{#each @model.errors.username as |error|}}\n  <div class="error">\n    {{error.message}}\n  </div>\n{{/each}}\n<label>Email: <Input @value={{@model.email}} /> </label>\n{{#each @model.errors.email as |error|}}\n  <div class="error">\n    {{error.message}}\n  </div>\n{{/each}}
\n
\n
\n \n

You can also access the special messages property on the error\nobject to get an array of all the error strings.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{{#each @model.errors.messages as |message|}}\n  <div class="error">\n    {{message}}\n  </div>\n{{/each}}
\n
\n
\n \n", + "itemtype": "property", + "name": "errors", + "access": "public", + "tagname": "", + "type": "{Errors}", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 589, + "description": "

This property holds the AdapterError object with which\nlast adapter operation was rejected.

\n", + "itemtype": "property", + "name": "adapterError", + "access": "public", + "tagname": "", + "type": "{AdapterError}", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1273, + "description": "

Represents the model's class name as a string. This can be used to look up the model's class name through\nStore's modelFor method.

\n

modelName is generated for you by Ember Data. It will be a lowercased, dasherized string.\nFor example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.modelFor('post').modelName; // 'post'\nstore.modelFor('blog-post').modelName; // 'blog-post'
\n
\n
\n \n

The most common place you'll want to access modelName is in your serializer's payloadKeyFromModelName method. For example, to change payload\nkeys to underscore (instead of dasherized), you might use the following code:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { underscore } from '@ember/string';\n\nexport default const PostSerializer = RESTSerializer.extend({\n  payloadKeyFromModelName(modelName) {\n    return underscore(modelName);\n  }\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "modelName", + "access": "public", + "tagname": "", + "type": "String", + "readonly": "", + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1502, + "description": "

The model's relationships as a map, keyed on the type of the\nrelationship. The value of each entry is an array containing a descriptor\nfor each relationship with that type, describing the name of the relationship\nas well as the type.

\n

For example, given the following model definition:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/blog.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { belongsTo, hasMany } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n   @hasMany('user') users;\n   @belongsTo('user') owner;\n   @hasMany('post') posts;\n }
\n
\n
\n \n

This computed property would return a map describing these\nrelationships, like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import { get } from '@ember/object';\nimport Blog from 'app/models/blog';\nimport User from 'app/models/user';\nimport Post from 'app/models/post';\n\nlet relationships = Blog.relationships;\nrelationships.get('user');\n//=> [ { name: 'users', kind: 'hasMany' },\n//     { name: 'owner', kind: 'belongsTo' } ]\nrelationships.get('post');\n//=> [ { name: 'posts', kind: 'hasMany' } ]
\n
\n
\n \n", + "itemtype": "property", + "name": "relationships", + "access": "public", + "tagname": "", + "static": 1, + "type": "Map", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1563, + "description": "

A hash containing lists of the model's relationships, grouped\nby the relationship kind. For example, given a model with this\ndefinition:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/blog.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { belongsTo, hasMany } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n   @hasMany('user') users;\n   @belongsTo('user') owner;\n\n   @hasMany('post') posts;\n }
\n
\n
\n \n

This property would contain the following:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
import { get } from '@ember/object';\nimport Blog from 'app/models/blog';\n\nlet relationshipNames = Blog.relationshipNames;\nrelationshipNames.hasMany;\n//=> ['users', 'posts']\nrelationshipNames.belongsTo;\n//=> ['owner']
\n
\n
\n \n", + "itemtype": "property", + "name": "relationshipNames", + "access": "public", + "tagname": "", + "static": 1, + "type": "Object", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1614, + "description": "

An array of types directly related to a model. Each type will be\nincluded once, regardless of the number of relationships it has with\nthe model.

\n

For example, given a model with this definition:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/blog.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { belongsTo, hasMany } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n   @hasMany('user') users;\n   @belongsTo('user') owner;\n\n   @hasMany('post') posts;\n }
\n
\n
\n \n

This property would contain the following:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
import { get } from '@ember/object';\nimport Blog from 'app/models/blog';\n\nlet relatedTypes = Blog.relatedTypes');\n//=> [ User, Post ]
\n
\n
\n \n", + "itemtype": "property", + "name": "relatedTypes", + "access": "public", + "tagname": "", + "static": 1, + "type": "Ember.Array", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1670, + "description": "

A map whose keys are the relationships of a model and whose values are\nrelationship descriptors.

\n

For example, given a model with this\ndefinition:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/blog.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { belongsTo, hasMany } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n   @hasMany('user') users;\n   @belongsTo('user') owner;\n\n   @hasMany('post') posts;\n }
\n
\n
\n \n

This property would contain the following:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
import { get } from '@ember/object';\nimport Blog from 'app/models/blog';\n\nlet relationshipsByName = Blog.relationshipsByName;\nrelationshipsByName.get('users');\n//=> { key: 'users', kind: 'hasMany', type: 'user', options: Object, isRelationship: true }\nrelationshipsByName.get('owner');\n//=> { key: 'owner', kind: 'belongsTo', type: 'user', options: Object, isRelationship: true }
\n
\n
\n \n", + "itemtype": "property", + "name": "relationshipsByName", + "access": "public", + "tagname": "", + "static": 1, + "type": "Map", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1738, + "description": "

A map whose keys are the fields of the model and whose values are strings\ndescribing the kind of the field. A model's fields are the union of all of its\nattributes and relationships.

\n

For example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/blog.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';\n\nexport default class BlogModel extends Model {\n   @hasMany('user') users;\n   @belongsTo('user') owner;\n\n   @hasMany('post') posts;\n\n   @attr('string') title;\n }
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import { get } from '@ember/object';\nimport Blog from 'app/models/blog'\n\nlet fields = Blog.fields;\nfields.forEach(function(kind, field) {\n   console.log(field, kind);\n });\n\n// prints:\n// users, hasMany\n// owner, belongsTo\n// posts, hasMany\n// title, attribute
\n
\n
\n \n", + "itemtype": "property", + "name": "fields", + "access": "public", + "tagname": "", + "static": 1, + "type": "Map", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1854, + "description": "

A map whose keys are the attributes of the model (properties\ndescribed by attr) and whose values are the meta object for the\nproperty.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr } from '@ember-data/model';\n\nexport default class PersonModel extends Model {\n   @attr('string') firstName;\n   @attr('string') lastName;\n   @attr('date') birthday;\n }
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import { get } from '@ember/object';\nimport Blog from 'app/models/blog'\n\nlet attributes = Person.attributes\n\nattributes.forEach(function(meta, name) {\n   console.log(name, meta);\n });\n\n// prints:\n// firstName {type: "string", isAttribute: true, options: Object, parentType: function, name: "firstName"}\n// lastName {type: "string", isAttribute: true, options: Object, parentType: function, name: "lastName"}\n// birthday {type: "date", isAttribute: true, options: Object, parentType: function, name: "birthday"}
\n
\n
\n \n", + "itemtype": "property", + "name": "attributes", + "access": "public", + "tagname": "", + "static": 1, + "type": "{Map}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1913, + "description": "

A map whose keys are the attributes of the model (properties\ndescribed by attr) and whose values are type of transformation\napplied to each attribute. This map does not include any\nattributes that do not have an transformation type.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr } from '@ember-data/model';\n\nexport default class PersonModel extends Model {\n   @attr firstName;\n   @attr('string') lastName;\n   @attr('date') birthday;\n }
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import { get } from '@ember/object';\nimport Person from 'app/models/person';\n\nlet transformedAttributes = Person.transformedAttributes\n\ntransformedAttributes.forEach(function(field, type) {\n   console.log(field, type);\n });\n\n// prints:\n// lastName string\n// birthday date
\n
\n
\n \n", + "itemtype": "property", + "name": "transformedAttributes", + "access": "public", + "tagname": "", + "static": 1, + "type": "{Map}", + "readonly": "", + "class": "Model", + "module": "@ember-data/model" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "EmberObject", + "type": "missing" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/model", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-NotFoundError-743ee0c647.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-NotFoundError-743ee0c647.json new file mode 100644 index 000000000..50b542465 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-NotFoundError-743ee0c647.json @@ -0,0 +1,49 @@ +{ + "data": { + "id": "ember-data-3.28.13-NotFoundError", + "type": "class", + "attributes": { + "name": "NotFoundError", + "shortname": "NotFoundError", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter/error", + "namespace": "", + "file": "../adapter/addon/error.js", + "line": 281, + "description": "

A NotFoundError equates to a HTTP 404 Not Found response status.\nIt is used by an adapter to signal that a request to the external API\nwas rejected because the resource could not be found on the API.

\n

An example use case would be to detect if the user has entered a route\nfor a specific model that does not exist. For example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n
import Route from '@ember/routing/route';\nimport { NotFoundError } from '@ember-data/adapter/error';\nimport { inject as service } from '@ember/service';\nimport { action } from '@ember/object';\n\nexport default class PostRoute extends Route {\n  @service store;\n  model(params) {\n    return this.get('store').findRecord('post', params.post_id);\n  }\n  @action\n  error(error, transition) {\n    if (error instanceof NotFoundError) {\n      // redirect to a list of all posts instead\n      this.transitionTo('posts');\n    } else {\n      // otherwise let the error bubble\n      return true;\n    }\n  }\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "AdapterError", + "methods": [], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-AdapterError", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/error", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-NumberTransform-6cc15c870c.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-NumberTransform-6cc15c870c.json new file mode 100644 index 000000000..25c68f37c --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-NumberTransform-6cc15c870c.json @@ -0,0 +1,102 @@ +{ + "data": { + "id": "ember-data-3.28.13-NumberTransform", + "type": "class", + "attributes": { + "name": "NumberTransform", + "shortname": "NumberTransform", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer", + "namespace": "", + "file": "../serializer/addon/-private/transforms/number.js", + "line": 11, + "description": "

The NumberTransform class is used to serialize and deserialize\nnumeric attributes on Ember Data record objects. This transform is\nused when number is passed as the type parameter to the\nattr function.

\n

Usage

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/score.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class ScoreModel extends Model {\n  @attr('number') value;\n  @belongsTo('player') player;\n  @attr('date') date;\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "Transform", + "methods": [ + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 80, + "description": "

When given a deserialized value from a record attribute this\nmethod must return the serialized value.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
import { isEmpty } from '@ember/utils';\n\nserialize(deserialized, options) {\n  return isEmpty(deserialized) ? null : Number(deserialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "deserialized", + "description": "The deserialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The serialized value" + }, + "class": "NumberTransform", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Transform" + }, + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 102, + "description": "

When given a serialized value from a JSON object this method must\nreturn the deserialized value for the record attribute.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
deserialize(serialized, options) {\n  return empty(serialized) ? null : Number(serialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deserialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "serialized", + "description": "The serialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The deserialized value" + }, + "class": "NumberTransform", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Transform" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Transform", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-PromiseManyArray-07460523fc.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-PromiseManyArray-07460523fc.json new file mode 100644 index 000000000..26c6c6033 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-PromiseManyArray-07460523fc.json @@ -0,0 +1,232 @@ +{ + "data": { + "id": "ember-data-3.28.13-PromiseManyArray", + "type": "class", + "attributes": { + "name": "PromiseManyArray", + "shortname": "PromiseManyArray", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/model", + "namespace": "", + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 14, + "description": "

This class is returned as the result of accessing an async hasMany relationship\non an instance of a Model extending from @ember-data/model.

\n

A PromiseManyArray is an array-like proxy that also proxies certain method calls\nto the underlying ManyArray in addition to being "promisified".

\n

Right now we proxy:

\n
    \n
  • reload()
  • \n
  • createRecord()
  • \n
\n

This promise-proxy behavior is primarily to ensure that async relationship interact\nnicely with templates. In your JS code you should resolve the promise first.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
const comments = await post.comments;
\n
\n
\n \n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 81, + "description": "

Iterate the proxied content. Called by the glimmer iterator in #each

\n", + "itemtype": "method", + "name": "forEach", + "params": [ + { + "name": "cb", + "description": "" + } + ], + "return": { + "description": "" + }, + "access": "private", + "tagname": "", + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 127, + "description": "

chain this promise

\n", + "itemtype": "method", + "name": "then", + "access": "public", + "tagname": "", + "params": [ + { + "name": "success", + "description": "" + }, + { + "name": "fail", + "description": "" + } + ], + "return": { + "description": "Promise" + }, + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 140, + "description": "

catch errors thrown by this promise

\n", + "itemtype": "method", + "name": "catch", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "" + } + ], + "return": { + "description": "Promise" + }, + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 151, + "description": "

run cleanup after this promise completes

\n", + "itemtype": "method", + "name": "finally", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "" + } + ], + "return": { + "description": "Promise" + }, + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 194, + "description": "

Reload the relationship

\n", + "itemtype": "method", + "name": "reload", + "access": "public", + "tagname": "", + "params": [ + { + "name": "options", + "description": "" + } + ], + "return": { + "description": "" + }, + "class": "PromiseManyArray", + "module": "@ember-data/model" + } + ], + "events": [], + "properties": [ + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 59, + "description": "

Retrieve the length of the content

\n", + "itemtype": "property", + "name": "length", + "access": "public", + "tagname": "", + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 98, + "description": "

Whether the loading promise is still pending

\n", + "itemtype": "property", + "name": "isPending", + "type": "Boolean", + "access": "public", + "tagname": "", + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 105, + "description": "

Whether the loading promise rejected

\n", + "itemtype": "property", + "name": "isRejected", + "type": "Boolean", + "access": "public", + "tagname": "", + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 112, + "description": "

Whether the loading promise succeeded

\n", + "itemtype": "property", + "name": "isFulfilled", + "type": "Boolean", + "access": "public", + "tagname": "", + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 119, + "description": "

Whether the loading promise completed (resolved or rejected)

\n", + "itemtype": "property", + "name": "isSettled", + "type": "Boolean", + "access": "public", + "tagname": "", + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 174, + "description": "

Retrieve the links for this relationship

\n", + "itemtype": "property", + "name": "links", + "access": "public", + "tagname": "", + "class": "PromiseManyArray", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/system/promise-many-array.ts", + "line": 184, + "description": "

Retrieve the meta for this relationship

\n", + "itemtype": "property", + "name": "meta", + "access": "public", + "tagname": "", + "class": "PromiseManyArray", + "module": "@ember-data/model" + } + ] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/model", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RESTAdapter-b5df0eb287.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RESTAdapter-b5df0eb287.json new file mode 100644 index 000000000..be0bc0327 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RESTAdapter-b5df0eb287.json @@ -0,0 +1,1815 @@ +{ + "data": { + "id": "ember-data-3.28.13-RESTAdapter", + "type": "class", + "attributes": { + "name": "RESTAdapter", + "shortname": "RESTAdapter", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter/rest", + "namespace": "", + "file": "../adapter/addon/rest.ts", + "line": 79, + "description": "

The REST adapter allows your store to communicate with an HTTP server by\ntransmitting JSON via XHR. Most Ember.js apps that consume a JSON API\nshould use the REST adapter.

\n

This adapter is designed around the idea that the JSON exchanged with\nthe server should be conventional.

\n

Success and failure

\n

The REST adapter will consider a success any response with a status code\nof the 2xx family ("Success"), as well as 304 ("Not Modified"). Any other\nstatus code will be considered a failure.

\n

On success, the request promise will be resolved with the full response\npayload.

\n

Failed responses with status code 422 ("Unprocessable Entity") will be\nconsidered "invalid". The response will be discarded, except for the\nerrors key. The request promise will be rejected with a InvalidError.\nThis error object will encapsulate the saved errors value.

\n

Any other status codes will be treated as an "adapter error". The request\npromise will be rejected, similarly to the "invalid" case, but with\nan instance of AdapterError instead.

\n

JSON Structure

\n

The REST adapter expects the JSON returned from your server to follow\nthese conventions.

\n

Object Root

\n

The JSON payload should be an object that contains the record inside a\nroot property. For example, in response to a GET request for\n/posts/1, the JSON should look like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
{\n  "posts": {\n    "id": 1,\n    "title": "I'm Running to Reform the W3C's Tag",\n    "author": "Yehuda Katz"\n  }\n}
\n
\n
\n \n

Similarly, in response to a GET request for /posts, the JSON should\nlook like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
{\n  "posts": [\n    {\n      "id": 1,\n      "title": "I'm Running to Reform the W3C's Tag",\n      "author": "Yehuda Katz"\n    },\n    {\n      "id": 2,\n      "title": "Rails is omakase",\n      "author": "D2H"\n    }\n  ]\n}
\n
\n
\n \n

Note that the object root can be pluralized for both a single-object response\nand an array response: the REST adapter is not strict on this. Further, if the\nHTTP server responds to a GET request to /posts/1 (e.g. the response to a\nfindRecord query) with more than one object in the array, Ember Data will\nonly display the object with the matching ID.

\n

Conventional Names

\n

Attribute names in your JSON payload should be the camelCased versions of\nthe attributes in your Ember.js models.

\n

For example, if you have a Person model:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr } from '@ember-data/model';\n\nexport default Model.extend({\n  firstName: attr('string'),\n  lastName: attr('string'),\n  occupation: attr('string')\n});
\n
\n
\n \n

The JSON returned should look like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
{\n  "people": {\n    "id": 5,\n    "firstName": "Zaphod",\n    "lastName": "Beeblebrox",\n    "occupation": "President"\n  }\n}
\n
\n
\n \n

Relationships

\n

Relationships are usually represented by ids to the record in the\nrelationship. The related records can then be sideloaded in the\nresponse under a key for the type.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
{\n  "posts": {\n    "id": 5,\n    "title": "I'm Running to Reform the W3C's Tag",\n    "author": "Yehuda Katz",\n    "comments": [1, 2]\n  },\n  "comments": [{\n    "id": 1,\n    "author": "User 1",\n    "message": "First!",\n  }, {\n    "id": 2,\n    "author": "User 2",\n    "message": "Good Luck!",\n  }]\n}
\n
\n
\n \n

If the records in the relationship are not known when the response\nis serialized it's also possible to represent the relationship as a\nURL using the links key in the response. Ember Data will fetch\nthis URL to resolve the relationship when it is accessed for the\nfirst time.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
{\n  "posts": {\n    "id": 5,\n    "title": "I'm Running to Reform the W3C's Tag",\n    "author": "Yehuda Katz",\n    "links": {\n      "comments": "/posts/5/comments"\n    }\n  }\n}
\n
\n
\n \n

Errors

\n

If a response is considered a failure, the JSON payload is expected to include\na top-level key errors, detailing any specific issues. For example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "errors": {\n    "msg": "Something went wrong"\n  }\n}
\n
\n
\n \n

This adapter does not make any assumptions as to the format of the errors\nobject. It will simply be passed along as is, wrapped in an instance\nof InvalidError or AdapterError. The serializer can interpret it\nafterwards.

\n

Customization

\n

Endpoint path customization

\n

Endpoint paths can be prefixed with a namespace by setting the namespace\nproperty on the adapter:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  namespace = 'api/1';\n}
\n
\n
\n \n

Requests for the Person model would now target /api/1/people/1.

\n

Host customization

\n

An adapter can target other hosts by setting the host property.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  host = 'https://api.example.com';\n}
\n
\n
\n \n

Headers customization

\n

Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary\nheaders can be set as key/value pairs on the RESTAdapter's headers\nobject and Ember Data will send them along with each ajax request.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { computed } from '@ember/object';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  headers: computed(function() {\n    return {\n      'API_KEY': 'secret key',\n      'ANOTHER_HEADER': 'Some header value'\n    };\n  }\n}
\n
\n
\n \n

headers can also be used as a computed property to support dynamic\nheaders. In the example below, the session object has been\ninjected into an adapter by Ember's container.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { computed } from '@ember/object';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  headers: computed('session.authToken', function() {\n    return {\n      'API_KEY': this.get('session.authToken'),\n      'ANOTHER_HEADER': 'Some header value'\n    };\n  })\n}
\n
\n
\n \n

In some cases, your dynamic headers may require data from some\nobject outside of Ember's observer system (for example\ndocument.cookie). You can use the\nvolatile\nfunction to set the property into a non-cached mode causing the headers to\nbe recomputed with every request.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { get } from '@ember/object';\nimport { computed } from '@ember/object';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  headers: computed(function() {\n    return {\n      'API_KEY': get(document.cookie.match(/apiKey\\=([^;]*)/), '1'),\n      'ANOTHER_HEADER': 'Some header value'\n    };\n  }).volatile()\n}
\n
\n
\n \n

@mainName @ember-data/adapter/rest\n @tag main

\n", + "_main": true, + "access": "public", + "tagname": "", + "is_constructor": 1, + "extends": "Adapter", + "uses": [ + "BuildURLMixin" + ], + "methods": [ + { + "file": "../adapter/addon/rest.ts", + "line": 374, + "description": "

By default, the RESTAdapter will send the query params sorted alphabetically to the\nserver.

\n

For example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.query('posts', { sort: 'price', category: 'pets' });
\n
\n
\n \n

will generate a requests like this /posts?category=pets&sort=price, even if the\nparameters were specified in a different order.

\n

That way the generated URL will be deterministic and that simplifies caching mechanisms\nin the backend.

\n

Setting sortQueryParams to a falsey value will respect the original order.

\n

In case you want to sort the query parameters with a different criteria, set\nsortQueryParams to your custom sort function.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  sortQueryParams(params) {\n    let sortedKeys = Object.keys(params).sort().reverse();\n    let len = sortedKeys.length, newParams = {};\n\n    for (let i = 0; i < len; i++) {\n      newParams[sortedKeys[i]] = params[sortedKeys[i]];\n    }\n\n    return newParams;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "sortQueryParams", + "params": [ + { + "name": "obj", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 556, + "description": "

Called by the store in order to fetch the JSON for a given\ntype and ID.

\n

The findRecord method makes an Ajax request to a URL computed by\nbuildURL, and returns a promise for the resulting payload.

\n

This method performs an HTTP GET request with the id provided as part of the query string.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "findRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 581, + "description": "

Called by the store in order to fetch a JSON array for all\nof the records for a given type.

\n

The findAll method makes an Ajax (HTTP GET) request to a URL computed by buildURL, and returns a\npromise for the resulting payload.

\n", + "itemtype": "method", + "name": "findAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "neverSet", + "description": "a value is never provided to this argument", + "type": "Undefined" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 607, + "description": "

Called by the store in order to fetch a JSON array for\nthe records that match a particular query.

\n

The query method makes an Ajax (HTTP GET) request to a URL\ncomputed by buildURL, and returns a promise for the resulting\npayload.

\n

The query argument is a simple JavaScript object that will be passed directly\nto the server as parameters.

\n", + "itemtype": "method", + "name": "query", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "recordArray", + "description": "", + "type": "AdapterPopulatedRecordArray" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 637, + "description": "

Called by the store in order to fetch a JSON object for\nthe record that matches a particular query.

\n

The queryRecord method makes an Ajax (HTTP GET) request to a URL\ncomputed by buildURL, and returns a promise for the resulting\npayload.

\n

The query argument is a simple JavaScript object that will be passed directly\nto the server as parameters.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "queryRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 672, + "description": "

Called by the store in order to fetch several records together if coalesceFindRequests is true

\n

For example, if the original payload looks like:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "id": 1,\n  "title": "Rails is omakase",\n  "comments": [ 1, 2, 3 ]\n}
\n
\n
\n \n

The IDs will be passed as a URL-encoded Array of IDs, in this form:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
ids[]=1&ids[]=2&ids[]=3
\n
\n
\n \n

Many servers, such as Rails and PHP, will automatically convert this URL-encoded array\ninto an Array for you on the server-side. If you want to encode the\nIDs, differently, just override this (one-line) method.

\n

The findMany method makes an Ajax (HTTP GET) request to a URL computed by buildURL, and returns a\npromise for the resulting payload.

\n", + "itemtype": "method", + "name": "findMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "ids", + "description": "", + "type": "Array" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 711, + "description": "

Called by the store in order to fetch a JSON array for\nthe unloaded records in a has-many relationship that were originally\nspecified as a URL (inside of links).

\n

For example, if your original payload looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
{\n  "post": {\n    "id": 1,\n    "title": "Rails is omakase",\n    "links": { "comments": "/posts/1/comments" }\n  }\n}
\n
\n
\n \n

This method will be called with the parent record and /posts/1/comments.

\n

The findHasMany method will make an Ajax (HTTP GET) request to the originally specified URL.

\n

The format of your links value will influence the final request URL via the urlPrefix method:

\n
    \n
  • Links beginning with //, http://, https://, will be used as is, with no further manipulation.

    \n
  • \n
  • Links beginning with a single / will have the current adapter's host value prepended to it.

    \n
  • \n
  • Links with no beginning / will have a parentURL prepended to it, via the current adapter's buildURL.

    \n
  • \n
\n", + "itemtype": "method", + "name": "findHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "relationship", + "description": "meta object describing the relationship", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 757, + "description": "

Called by the store in order to fetch the JSON for the unloaded record in a\nbelongs-to relationship that was originally specified as a URL (inside of\nlinks).

\n

For example, if your original payload looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
{\n  "person": {\n    "id": 1,\n    "name": "Tom Dale",\n    "links": { "group": "/people/1/group" }\n  }\n}
\n
\n
\n \n

This method will be called with the parent record and /people/1/group.

\n

The findBelongsTo method will make an Ajax (HTTP GET) request to the originally specified URL.

\n

The format of your links value will influence the final request URL via the urlPrefix method:

\n
    \n
  • Links beginning with //, http://, https://, will be used as is, with no further manipulation.

    \n
  • \n
  • Links beginning with a single / will have the current adapter's host value prepended to it.

    \n
  • \n
  • Links with no beginning / will have a parentURL prepended to it, via the current adapter's buildURL.

    \n
  • \n
\n", + "itemtype": "method", + "name": "findBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "relationship", + "description": "meta object describing the relationship", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 802, + "description": "

Called by the store when a newly created record is\nsaved via the save method on a model record instance.

\n

The createRecord method serializes the record and makes an Ajax (HTTP POST) request\nto a URL computed by buildURL.

\n

See serialize for information on how to customize the serialized form\nof a record.

\n", + "itemtype": "method", + "name": "createRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 827, + "description": "

Called by the store when an existing record is saved\nvia the save method on a model record instance.

\n

The updateRecord method serializes the record and makes an Ajax (HTTP PUT) request\nto a URL computed by buildURL.

\n

See serialize for information on how to customize the serialized form\nof a record.

\n", + "itemtype": "method", + "name": "updateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 853, + "description": "

Called by the store when a record is deleted.

\n

The deleteRecord method makes an Ajax (HTTP DELETE) request to a URL computed by buildURL.

\n", + "itemtype": "method", + "name": "deleteRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 895, + "description": "

Organize records into groups, each of which is to be passed to separate\ncalls to findMany.

\n

This implementation groups together records that have the same base URL but\ndiffering ids. For example /comments/1 and /comments/2 will be grouped together\nbecause we know findMany can coalesce them together as /comments?ids[]=1&ids[]=2

\n

It also supports urls where ids are passed as a query param, such as /comments?id=1\nbut not those where there is more than 1 query param such as /comments?id=2&name=David\nCurrently only the query param of id is supported. If you need to support others, please\noverride this or the _stripIDFromURL method.

\n

It does not group records that have differing base urls, such as for example: /posts/1/comments/2\nand /posts/2/comments/3

\n", + "itemtype": "method", + "name": "groupRecordsForFindMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "an array of arrays of records, each of which is to be\n loaded separately by `findMany`.", + "type": "Array" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 964, + "description": "

Takes an ajax response, and returns the json payload or an error.

\n

By default this hook just returns the json payload passed to it.\nYou might want to override it in two cases:

\n
    \n
  1. Your API might return useful results in the response headers.\nResponse headers are passed in as the second argument.

    \n
  2. \n
  3. Your API might return errors as successful responses with status code\n200 and an Errors text or object. You can return a InvalidError or a\nAdapterError (or a sub class) from this hook and it will automatically\nreject the promise and put your record into the invalid or error state.

    \n
  4. \n
\n

Returning a InvalidError from this method will cause the\nrecord to transition into the invalid state and make the\nerrors object available on the record. When returning an\nInvalidError the store will attempt to normalize the error data\nreturned from the server using the serializer's extractErrors\nmethod.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "handleResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "requestData", + "description": "- the original request information", + "type": "Object" + } + ], + "return": { + "description": "response", + "type": "Object | AdapterError" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1027, + "description": "

Default handleResponse implementation uses this hook to decide if the\nresponse is a success.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "isSuccess", + "access": "public", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1043, + "description": "

Default handleResponse implementation uses this hook to decide if the\nresponse is an invalid error.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "isInvalid", + "access": "public", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1059, + "description": "

Takes a URL, an HTTP method and a hash of data, and makes an\nHTTP request.

\n

When the server responds with a payload, Ember Data will call into extractSingle\nor extractArray (depending on whether the original query was for one record or\nmany records).

\n

By default, ajax method has the following behavior:

\n
    \n
  • It sets the response dataType to "json"
  • \n
  • If the HTTP method is not "GET", it sets the Content-Type to be\napplication/json; charset=utf-8
  • \n
  • If the HTTP method is not "GET", it stringifies the data passed in. The\ndata is the serialized record in the case of a save.
  • \n
  • Registers success and failure handlers.
  • \n
\n", + "itemtype": "method", + "name": "ajax", + "access": "private", + "tagname": "", + "params": [ + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "type", + "description": "The request type GET, POST, PUT, DELETE etc.", + "type": "String" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1125, + "itemtype": "method", + "name": "_ajaxRequest", + "access": "private", + "tagname": "", + "params": [ + { + "name": "options", + "description": "jQuery ajax options to be used for the ajax request", + "type": "Object" + } + ], + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1157, + "itemtype": "method", + "name": "ajaxOptions", + "access": "private", + "tagname": "", + "params": [ + { + "name": "url", + "description": "", + "type": "String" + }, + { + "name": "type", + "description": "The request type GET, POST, PUT, DELETE etc.", + "type": "String" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1232, + "itemtype": "method", + "name": "parseErrorResponse", + "access": "private", + "tagname": "", + "params": [ + { + "name": "responseText", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1250, + "itemtype": "method", + "name": "normalizeErrorResponse", + "access": "private", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "errors payload", + "type": "Array" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1272, + "description": "

Generates a detailed ("friendly") error message, with plenty\nof information for debugging (good luck!)

\n", + "itemtype": "method", + "name": "generatedDetailedMessage", + "access": "private", + "tagname": "", + "params": [ + { + "name": "status", + "description": "", + "type": "Number" + }, + { + "name": "headers", + "description": "", + "type": "Object" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "requestData", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "detailed error message", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 1304, + "description": "

Used by findAll and findRecord to build the query's data hash\nsupplied to the ajax method.

\n", + "itemtype": "method", + "name": "buildQuery", + "since": "2.5.0", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/index.ts", + "line": 232, + "description": "

The findRecord() method is invoked when the store is asked for a record that\nhas not previously been loaded. In response to findRecord() being called, you\nshould query your persistence layer for a record with the given ID. The findRecord\nmethod should return a promise that will resolve to a JavaScript object that will be\nnormalized by the serializer.

\n

Here is an example of the findRecord implementation:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findRecord(store, type, id, snapshot) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}/${id}`).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 275, + "description": "

The findAll() method is used to retrieve all records for a given type.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findAll(store, type) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "neverSet", + "description": "a value is never provided to this argument", + "type": "Undefined" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 314, + "description": "

This method is called when you call query on the store.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  query(store, type, query) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`, query).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "query", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "recordArray", + "description": "", + "type": "AdapterPopulatedRecordArray" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 354, + "description": "

The queryRecord() method is invoked when the store is asked for a single\nrecord through a query object.

\n

In response to queryRecord() being called, you should always fetch fresh\ndata. Once found, you can asynchronously call the store's push() method\nto push the record into the store.

\n

Here is an example queryRecord implementation:

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Adapter, { BuildURLMixin } from '@ember-data/adapter';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) {\n  queryRecord(store, type, query) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.getJSON(`/${type.modelName}`, query).then(function(data) {\n        resolve(data);\n      }, function(jqXHR) {\n        reject(jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "queryRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "", + "type": "Subclass of Model" + }, + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "adapterOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 400, + "description": "

If the globally unique IDs for your records should be generated on the client,\nimplement the generateIdForRecord() method. This method will be invoked\neach time you create a new record, and the value returned from it will be\nassigned to the record's primaryKey.

\n

Most traditional REST-like HTTP APIs will not use this method. Instead, the ID\nof the record will be set by the server, and your adapter will update the store\nwith the new ID when it calls didCreateRecord(). Only implement this method if\nyou intend to generate record IDs on the client-side.

\n

The generateIdForRecord() method will be invoked with the requesting store as\nthe first parameter and the newly created record as the second parameter:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
import Adapter from '@ember-data/adapter';\nimport { v4 } from 'uuid';\n\nexport default class ApplicationAdapter extends Adapter {\n  generateIdForRecord(store, type, inputProperties) {\n    return v4();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "generateIdForRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "inputProperties", + "description": "a hash of properties to set on the\n newly created record.", + "type": "Object" + } + ], + "return": { + "description": "id", + "type": "(String|Number)" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 434, + "description": "

Proxies to the serializer's serialize method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import Adapter from '@ember-data/adapter';\n\nexport default class ApplicationAdapter extends Adapter {\n  createRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let url = `/${type.modelName}`;\n\n    // ...\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "serialized snapshot", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 462, + "description": "

Implement this method in a subclass to handle the creation of\nnew records.

\n

Serializes the record and sends it to the server.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  createRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n\n    return new RSVP.Promise(function (resolve, reject) {\n      $.ajax({\n        type: 'POST',\n        url: `/${type.modelName}`,\n        dataType: 'json',\n        data: data\n      }).then(function (data) {\n        run(null, resolve, data);\n      }, function (jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "createRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 512, + "description": "

Implement this method in a subclass to handle the updating of\na record.

\n

Serializes the record update and sends it to the server.

\n

The updateRecord method is expected to return a promise that will\nresolve with the serialized record. This allows the backend to\ninform the Ember Data store the current state of this record after\nthe update. If it is not possible to return a serialized record\nthe updateRecord promise can also resolve with undefined and the\nEmber Data store will assume all of the updates were successfully\napplied on the backend.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  updateRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let id = snapshot.id;\n\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'PUT',\n        url: `/${type.modelName}/${id}`,\n        dataType: 'json',\n        data: data\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "updateRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 571, + "description": "

Implement this method in a subclass to handle the deletion of\na record.

\n

Sends a delete request for the record to the server.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  deleteRecord(store, type, snapshot) {\n    let data = this.serialize(snapshot, { includeId: true });\n    let id = snapshot.id;\n\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'DELETE',\n        url: `/${type.modelName}/${id}`,\n        dataType: 'json',\n        data: data\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deleteRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the record", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 644, + "description": "

The store will call findMany instead of multiple findRecord\nrequests to find multiple records at once if coalesceFindRequests\nis true.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n
import Adapter from '@ember-data/adapter';\nimport { run } from '@ember/runloop';\nimport RSVP from 'RSVP';\nimport $ from 'jquery';\n\nexport default class ApplicationAdapter extends Adapter {\n  findMany(store, type, ids, snapshots) {\n    return new RSVP.Promise(function(resolve, reject) {\n      $.ajax({\n        type: 'GET',\n        url: `/${type.modelName}/`,\n        dataType: 'json',\n        data: { filter: { id: ids.join(',') } }\n      }).then(function(data) {\n        run(null, resolve, data);\n      }, function(jqXHR) {\n        jqXHR.then = null; // tame jQuery's ill mannered promises\n        run(null, reject, jqXHR);\n      });\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "findMany", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "type", + "description": "the Model class of the records", + "type": "Model" + }, + { + "name": "ids", + "description": "", + "type": "Array" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 683, + "description": "

Organize records into groups, each of which is to be passed to separate\ncalls to findMany.

\n

For example, if your API has nested URLs that depend on the parent, you will\nwant to group records by their parent.

\n

The default implementation returns the records as a single group.

\n", + "itemtype": "method", + "name": "groupRecordsForFindMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "an array of arrays of records, each of which is to be\n loaded separately by `findMany`.", + "type": "Array" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 703, + "description": "

This method is used by the store to determine if the store should\nreload a record from the adapter when a record is requested by\nstore.findRecord.

\n

If this method returns true, the store will re-fetch a record from\nthe adapter. If this method returns false, the store will resolve\nimmediately using the cached record.

\n

For example, if you are building an events ticketing system, in which users\ncan only reserve tickets for 20 minutes at a time, and want to ensure that\nin each route you have data that is no more than 20 minutes old you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
shouldReloadRecord(store, ticketSnapshot) {\n  let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');\n  let timeDiff = moment().diff(lastAccessedAt, 'minutes');\n\n  if (timeDiff > 20) {\n    return true;\n  } else {\n    return false;\n  }\n}
\n
\n
\n \n

This method would ensure that whenever you do store.findRecord('ticket', id) you will always get a ticket that is no more than 20 minutes old. In\ncase the cached version is more than 20 minutes old, findRecord will not\nresolve until you fetched the latest version.

\n

By default this hook returns false, as most UIs should not block user\ninteractions while waiting on data update.

\n

Note that, with default settings, shouldBackgroundReloadRecord will always\nre-fetch the records in the background even if shouldReloadRecord returns\nfalse. You can override shouldBackgroundReloadRecord if this does not\nsuit your use case.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldReloadRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 754, + "description": "

This method is used by the store to determine if the store should\nreload all records from the adapter when records are requested by\nstore.findAll.

\n

If this method returns true, the store will re-fetch all records from\nthe adapter. If this method returns false, the store will resolve\nimmediately using the cached records.

\n

For example, if you are building an events ticketing system, in which users\ncan only reserve tickets for 20 minutes at a time, and want to ensure that\nin each route you have data that is no more than 20 minutes old you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
shouldReloadAll(store, snapshotArray) {\n  let snapshots = snapshotArray.snapshots();\n\n  return snapshots.any((ticketSnapshot) => {\n    let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');\n    let timeDiff = moment().diff(lastAccessedAt, 'minutes');\n\n    if (timeDiff > 20) {\n      return true;\n    } else {\n      return false;\n    }\n  });\n}
\n
\n
\n \n

This method would ensure that whenever you do store.findAll('ticket') you\nwill always get a list of tickets that are no more than 20 minutes old. In\ncase a cached version is more than 20 minutes old, findAll will not\nresolve until you fetched the latest versions.

\n

By default, this method returns true if the passed snapshotRecordArray\nis empty (meaning that there are no records locally available yet),\notherwise, it returns false.

\n

Note that, with default settings, shouldBackgroundReloadAll will always\nre-fetch all the records in the background even if shouldReloadAll returns\nfalse. You can override shouldBackgroundReloadAll if this does not suit\nyour use case.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldReloadAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 810, + "description": "

This method is used by the store to determine if the store should\nreload a record after the store.findRecord method resolves a\ncached record.

\n

This method is only checked by the store when the store is\nreturning a cached record.

\n

If this method returns true the store will re-fetch a record from\nthe adapter.

\n

For example, if you do not want to fetch complex data over a mobile\nconnection, or if the network is down, you can implement\nshouldBackgroundReloadRecord as follows:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
shouldBackgroundReloadRecord(store, snapshot) {\n  let { downlink, effectiveType } = navigator.connection;\n\n  return downlink > 0 && effectiveType === '4g';\n}
\n
\n
\n \n

By default, this hook returns true so the data for the record is updated\nin the background.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldBackgroundReloadRecord", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 847, + "description": "

This method is used by the store to determine if the store should\nreload a record array after the store.findAll method resolves\nwith a cached record array.

\n

This method is only checked by the store when the store is\nreturning a cached record array.

\n

If this method returns true the store will re-fetch all records\nfrom the adapter.

\n

For example, if you do not want to fetch complex data over a mobile\nconnection, or if the network is down, you can implement\nshouldBackgroundReloadAll as follows:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
shouldBackgroundReloadAll(store, snapshotArray) {\n  let { downlink, effectiveType } = navigator.connection;\n\n  return downlink > 0 && effectiveType === '4g';\n}
\n
\n
\n \n

By default this method returns true, indicating that a background reload\nshould always be triggered.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "shouldBackgroundReloadAll", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "snapshotRecordArray", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 42, + "description": "

Builds a URL for a given type and optional ID.

\n

By default, it pluralizes the type's name (for example, 'post'\nbecomes 'posts' and 'person' becomes 'people'). To override the\npluralization see pathForType.

\n

If an ID is specified, it adds the ID to the path generated\nfor the type, separated by a /.

\n

When called by RESTAdapter.findMany() the id and snapshot parameters\nwill be arrays of ids and snapshots.

\n", + "itemtype": "method", + "name": "buildURL", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "single id or array of ids or query", + "type": "(String|Array|Object)" + }, + { + "name": "snapshot", + "description": "single snapshot or array of snapshots", + "type": "(Snapshot|SnapshotRecordArray)" + }, + { + "name": "requestType", + "description": "", + "type": "String" + }, + { + "name": "query", + "description": "object of query parameters to send for query requests.", + "type": "Object" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 97, + "itemtype": "method", + "name": "_buildURL", + "access": "private", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 132, + "description": "

Builds a URL for a store.findRecord(type, id) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/user.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindRecord(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id, snapshot);\n    return `${baseUrl}/users/${snapshot.adapterOptions.user_id}/playlists/${id}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 160, + "description": "

Builds a URL for a store.findAll(type) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindAll(modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName);\n    return `${baseUrl}/data/comments.json`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "SnapshotRecordArray" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 186, + "description": "

Builds a URL for a store.query(type, query) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  host = 'https://api.github.com';\n  urlForQuery (query, modelName) {\n    switch(modelName) {\n      case 'repo':\n        return `https://api.github.com/orgs/${query.orgId}/repos`;\n      default:\n        return super.urlForQuery(...arguments);\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForQuery", + "access": "public", + "tagname": "", + "params": [ + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 217, + "description": "

Builds a URL for a store.queryRecord(type, query) call.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForQueryRecord({ slug }, modelName) {\n    let baseUrl = this.buildURL();\n    return `${baseUrl}/${encodeURIComponent(slug)}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForQueryRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "query", + "description": "", + "type": "Object" + }, + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 243, + "description": "

Builds a URL for coalescing multiple store.findRecord(type, id)\nrecords into 1 request when the adapter's coalesceFindRequests\nproperty is true.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForFindMany(ids, modelName) {\n    let baseUrl = this.buildURL();\n    return `${baseUrl}/coalesce`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "ids", + "description": "", + "type": "Array" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshots", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 272, + "description": "

Builds a URL for fetching an async hasMany relationship when a URL\nis not provided by the server.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindHasMany(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id);\n    return `${baseUrl}/relationships`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 300, + "description": "

Builds a URL for fetching an async belongsTo relationship when a url\nis not provided by the server.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  urlForFindBelongsTo(id, modelName, snapshot) {\n    let baseUrl = this.buildURL(modelName, id);\n    return `${baseUrl}/relationships`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForFindBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 328, + "description": "

Builds a URL for a record.save() call when the record was created\nlocally using store.createRecord().

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForCreateRecord(modelName, snapshot) {\n    return super.urlForCreateRecord(...arguments) + '/new';\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForCreateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 354, + "description": "

Builds a URL for a record.save() call when the record has been updated locally.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForUpdateRecord(id, modelName, snapshot) {\n    return `/${id}/feed?access_token=${snapshot.adapterOptions.token}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForUpdateRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 380, + "description": "

Builds a URL for a record.save() call when the record has been deleted locally.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  urlForDeleteRecord(id, modelName, snapshot) {\n    return super.urlForDeleteRecord(...arguments) + '/destroy';\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "urlForDeleteRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "id", + "description": "", + "type": "String" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + } + ], + "return": { + "description": "url", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 406, + "itemtype": "method", + "name": "urlPrefix", + "access": "private", + "tagname": "", + "params": [ + { + "name": "path", + "description": "", + "type": "String" + }, + { + "name": "parentURL", + "description": "", + "type": "String" + } + ], + "return": { + "description": "urlPrefix", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + }, + { + "file": "../adapter/addon/-private/build-url-mixin.ts", + "line": 447, + "description": "

Determines the pathname for a given type.

\n

By default, it pluralizes the type's name (for example,\n'post' becomes 'posts' and 'person' becomes 'people').

\n

Pathname customization

\n

For example, if you have an object LineItem with an\nendpoint of /line_items/.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { decamelize } from '@ember/string';\nimport { pluralize } from 'ember-inflector';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  pathForType(modelName) {\n    var decamelized = decamelize(modelName);\n    return pluralize(decamelized);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "pathForType", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "path", + "type": "String" + }, + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "BuildURLMixin" + } + ], + "events": [], + "properties": [ + { + "file": "../adapter/addon/rest.ts", + "line": 342, + "description": "

If jQuery or nAjax are installed, this property\n allows fetch to still be used instead when true.

\n", + "itemtype": "property", + "name": "useFetch", + "type": "{Boolean}", + "access": "public", + "tagname": "", + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 432, + "description": "

By default the RESTAdapter will send each find request coming from a store.find\nor from accessing a relationship separately to the server. If your server supports passing\nids as a query string, you can set coalesceFindRequests to true to coalesce all find requests\nwithin a single runloop.

\n

For example, if you have an initial payload of:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
{\n  post: {\n    id: 1,\n    comments: [1, 2]\n  }\n}
\n
\n
\n \n

By default calling post.get('comments') will trigger the following requests(assuming the\ncomments haven't been loaded before):

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
GET /comments/1\nGET /comments/2
\n
\n
\n \n

If you set coalesceFindRequests to true it will instead trigger the following request:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
GET /comments?ids[]=1&ids[]=2
\n
\n
\n \n

Setting coalesceFindRequests to true also works for store.find requests and belongsTo\nrelationships accessed within the same runloop. If you set coalesceFindRequests: true

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.findRecord('comment', 1);\nstore.findRecord('comment', 2);
\n
\n
\n \n

will also send a request to: GET /comments?ids[]=1&ids[]=2

\n

Note: Requests coalescing rely on URL building strategy. So if you override buildURL in your app\ngroupRecordsForFindMany more likely should be overridden as well in order for coalescing to work.

\n", + "itemtype": "property", + "name": "coalesceFindRequests", + "access": "public", + "tagname": "", + "type": "{boolean}", + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 492, + "description": "

Endpoint paths can be prefixed with a namespace by setting the namespace\nproperty on the adapter:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  namespace = 'api/1';\n}
\n
\n
\n \n

Requests for the Post model would now target /api/1/post/.

\n", + "itemtype": "property", + "name": "namespace", + "access": "public", + "tagname": "", + "type": "{String}", + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 511, + "description": "

An adapter can target other hosts by setting the host property.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  host = 'https://api.example.com';\n}
\n
\n
\n \n

Requests for the Post model would now target https://api.example.com/post/.

\n", + "itemtype": "property", + "name": "host", + "access": "public", + "tagname": "", + "type": "{String}", + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/rest.ts", + "line": 529, + "description": "

Some APIs require HTTP headers, e.g. to provide an API\nkey. Arbitrary headers can be set as key/value pairs on the\nRESTAdapter's headers object and Ember Data will send them\nalong with each ajax request. For dynamic headers see headers\ncustomization.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { computed } from '@ember/object';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  headers: computed(function() {\n    return {\n      'API_KEY': 'secret key',\n      'ANOTHER_HEADER': 'Some header value'\n    };\n  })\n}
\n
\n
\n \n", + "itemtype": "property", + "name": "headers", + "access": "public", + "tagname": "", + "type": "{Object}", + "class": "RESTAdapter", + "module": "@ember-data/adapter/rest" + }, + { + "file": "../adapter/addon/index.ts", + "line": 208, + "description": "

If you would like your adapter to use a custom serializer you can\nset the defaultSerializer property to be the name of the custom\nserializer.

\n

Note the defaultSerializer serializer has a lower priority than\na model specific serializer (i.e. PostSerializer) or the\napplication serializer.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/django.js
1\n2\n3\n4\n5\n
import Adapter from '@ember-data/adapter';\n\nexport default Adapter.extend({\n  defaultSerializer: 'django'\n});
\n
\n
\n \n", + "deprecated": true, + "itemtype": "property", + "name": "defaultSerializer", + "access": "public", + "tagname": "", + "type": "{String}", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + }, + { + "file": "../adapter/addon/index.ts", + "line": 622, + "description": "

By default the store will try to coalesce all fetchRecord calls within the same runloop\ninto as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call.\nYou can opt out of this behaviour by either not implementing the findMany hook or by setting\ncoalesceFindRequests to false.

\n", + "itemtype": "property", + "name": "coalesceFindRequests", + "access": "public", + "tagname": "", + "type": "{boolean}", + "class": "RESTAdapter", + "module": "@ember-data/adapter", + "inherited": true, + "inheritedFrom": "Adapter" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Adapter", + "type": "class" + } + }, + "descendants": { + "data": [ + { + "type": "class", + "id": "ember-data-3.28.13-JSONAPIAdapter" + } + ] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/rest", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RESTSerializer-e01f8ddf48.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RESTSerializer-e01f8ddf48.json new file mode 100644 index 000000000..f107e1632 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RESTSerializer-e01f8ddf48.json @@ -0,0 +1,1951 @@ +{ + "data": { + "id": "ember-data-3.28.13-RESTSerializer", + "type": "class", + "attributes": { + "name": "RESTSerializer", + "shortname": "RESTSerializer", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer/rest", + "namespace": "", + "file": "../serializer/addon/rest.js", + "line": 18, + "description": "

Normally, applications will use the RESTSerializer by implementing\nthe normalize method.

\n

This allows you to do whatever kind of munging you need and is\nespecially useful if your server is inconsistent and you need to\ndo munging differently for many different kinds of responses.

\n

See the normalize documentation for more information.

\n

Across the Board Normalization

\n

There are also a number of hooks that you might find useful to define\nacross-the-board rules for your payload. These rules will be useful\nif your server is consistent, or if you're building an adapter for\nan infrastructure service, like Firebase, and want to encode service\nconventions.

\n

For example, if all of your keys are underscored and all-caps, but\notherwise consistent with the names you use in your models, you\ncan implement across-the-board rules for how to convert an attribute\nname in your model to a key in your JSON.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { underscore } from '@ember/string';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  keyForAttribute(attr, method) {\n    return underscore(attr).toUpperCase();\n  }\n}
\n
\n
\n \n

You can also implement keyForRelationship, which takes the name\nof the relationship as the first parameter, the kind of\nrelationship (hasMany or belongsTo) as the second parameter, and\nthe method (serialize or deserialize) as the third parameter.\n @mainName @ember-data/serializer/rest\n @tag main

\n", + "_main": true, + "access": "public", + "tagname": "", + "extends": "JSONSerializer", + "methods": [ + { + "file": "../serializer/addon/rest.js", + "line": 63, + "description": "

keyForPolymorphicType can be used to define a custom key when\nserializing and deserializing a polymorphic type. By default, the\nreturned key is ${key}Type.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import RESTSerializer from '@ember-data/serializer/rest';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  keyForPolymorphicType(key, relationship) {\n    let relationshipKey = this.keyForRelationship(key);\n\n    return 'type-' + relationshipKey;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForPolymorphicType", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "typeClass", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 95, + "description": "

Normalizes a part of the JSON payload returned by\nthe server. You should override this method, munge the hash\nand call super if you have generic normalization to do.

\n

It takes the type of the record that is being normalized\n(as a Model class), the property where the hash was\noriginally found, and the hash to normalize.

\n

For example, if you have a payload that looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
{\n  "post": {\n    "id": 1,\n    "title": "Rails is omakase",\n    "comments": [ 1, 2 ]\n  },\n  "comments": [{\n    "id": 1,\n    "body": "FIRST"\n  }, {\n    "id": 2,\n    "body": "Rails is unagi"\n  }]\n}
\n
\n
\n \n

The normalize method will be called three times:

\n
    \n
  • With App.Post, "posts" and { id: 1, title: "Rails is omakase", ... }
  • \n
  • With App.Comment, "comments" and { id: 1, body: "FIRST" }
  • \n
  • With App.Comment, "comments" and { id: 2, body: "Rails is unagi" }
  • \n
\n

You can use this method, for example, to normalize underscored keys to camelized\nor other general-purpose normalizations. You will only need to implement\nnormalize and manipulate the payload as desired.

\n

For example, if the IDs under "comments" are provided as _id instead of\nid, you can specify how to normalize just the comments:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import RESTSerializer from '@ember-data/serializer/rest';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  normalize(model, hash, prop) {\n    if (prop === 'comments') {\n      hash.id = hash._id;\n      delete hash._id;\n    }\n\n    return super.normalize(...arguments);\n  }\n}
\n
\n
\n \n

On each call to the normalize method, the third parameter (prop) is always\none of the keys that were in the original payload or in the result of another\nnormalization as normalizeResponse.

\n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Model" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + }, + { + "name": "prop", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 163, + "description": "

Normalizes an array of resource payloads and returns a JSON-API Document\nwith primary data and, if any, included data as { data, included }.

\n", + "itemtype": "method", + "name": "_normalizeArray", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "arrayHash", + "description": "", + "type": "Object" + }, + { + "name": "prop", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 214, + "itemtype": "method", + "name": "_normalizeResponse", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + }, + { + "name": "isSingle", + "description": "", + "type": "Boolean" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 368, + "description": "

This method allows you to push a payload containing top-level\ncollections of records organized per type.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n
{\n  "posts": [{\n    "id": "1",\n    "title": "Rails is omakase",\n    "author", "1",\n    "comments": [ "1" ]\n  }],\n  "comments": [{\n    "id": "1",\n    "body": "FIRST"\n  }],\n  "users": [{\n    "id": "1",\n    "name": "@d2h"\n  }]\n}
\n
\n
\n \n

It will first normalize the payload, so you can use this to push\nin data streaming in from your server structured the same way\nthat fetches and saves are structured.

\n", + "itemtype": "method", + "name": "pushPayload", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 429, + "description": "

This method is used to convert each JSON root key in the payload\ninto a modelName that it can use to look up the appropriate model for\nthat part of the payload.

\n

For example, your server may send a model name that does not correspond with\nthe name of the model in your app. Let's take a look at an example model,\nand an example payload:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n
import Model from '@ember-data/model';\n\nexport default class Post extends Model {}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
  {\n    "blog/post": {\n      "id": "1\n    }\n  }
\n
\n
\n \n

Ember Data is going to normalize the payload's root key for the modelName. As a result,\nit will try to look up the "blog/post" model. Since we don't have a model called "blog/post"\n(or a file called app/models/blog/post.js in ember-cli), Ember Data will throw an error\nbecause it cannot find the "blog/post" model.

\n

Since we want to remove this namespace, we can define a serializer for the application that will\nremove "blog/" from the payload key whenver it's encountered by Ember Data:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import RESTSerializer from '@ember-data/serializer/rest';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  modelNameFromPayloadKey(payloadKey) {\n    if (payloadKey === 'blog/post') {\n      return super.modelNameFromPayloadKey(payloadKey.replace('blog/', ''));\n    } else {\n     return super.modelNameFromPayloadKey(payloadKey);\n    }\n  }\n}
\n
\n
\n \n

After refreshing, Ember Data will appropriately look up the "post" model.

\n

By default the modelName for a model is its\nname in dasherized form. This means that a payload key like "blogPost" would be\nnormalized to "blog-post" when Ember Data looks up the model. Usually, Ember Data\ncan use the correct inflection to do this for you. Most of the time, you won't\nneed to override modelNameFromPayloadKey for this purpose.

\n", + "itemtype": "method", + "name": "modelNameFromPayloadKey", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "the model's modelName", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 493, + "description": "

Called when a record is saved in order to convert the\nrecord into JSON.

\n

By default, it creates a JSON object with a key for\neach attribute and belongsTo relationship.

\n

For example, consider this model:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class Comment extends Model {\n  @attr title\n  @attr body\n\n  @belongsTo('user') author\n}
\n
\n
\n \n

The default serialization would create a JSON object like:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "title": "Rails is unagi",\n  "body": "Rails? Omakase? O_O",\n  "author": 12\n}
\n
\n
\n \n

By default, attributes are passed through as-is, unless\nyou specified an attribute type (attr('date')). If\nyou specify a transform, the JavaScript value will be\nserialized when inserted into the JSON hash.

\n

By default, belongs-to relationships are converted into\nIDs when inserted into the JSON hash.

\n

IDs

\n

serialize takes an options hash with a single option:\nincludeId. If this option is true, serialize will,\nby default include the ID in the JSON object it builds.

\n

The adapter passes in includeId: true when serializing\na record for createRecord, but not for updateRecord.

\n

Customization

\n

Your server may expect a different JSON format than the\nbuilt-in serialization format.

\n

In that case, you can implement serialize yourself and\nreturn a JSON hash of your choosing.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import RESTSerializer from '@ember-data/serializer/rest';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  serialize(snapshot, options) {\n    let json = {\n      POST_TTL: snapshot.attr('title'),\n      POST_BDY: snapshot.attr('body'),\n      POST_CMS: snapshot.hasMany('comments', { ids: true })\n    };\n\n    if (options.includeId) {\n      json.POST_ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}
\n
\n
\n \n

Customizing an App-Wide Serializer

\n

If you want to define a serializer for your entire\napplication, you'll probably want to use eachAttribute\nand eachRelationship on the record.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { pluralize } from 'ember-inflector';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  serialize(snapshot, options) {\n    let json = {};\n\n    snapshot.eachAttribute(function(name) {\n      json[serverAttributeName(name)] = snapshot.attr(name);\n    });\n\n    snapshot.eachRelationship(function(name, relationship) {\n      if (relationship.kind === 'hasMany') {\n        json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n      }\n    });\n\n    if (options.includeId) {\n      json.ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}\n\nfunction serverAttributeName(attribute) {\n  return attribute.underscore().toUpperCase();\n}\n\nfunction serverHasManyName(name) {\n  return serverAttributeName(singularize(name)) + "_IDS";\n}
\n
\n
\n \n

This serializer will generate JSON that looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "TITLE": "Rails is omakase",\n  "BODY": "Yep. Omakase.",\n  "COMMENT_IDS": [ 1, 2, 3 ]\n}
\n
\n
\n \n

Tweaking the Default JSON

\n

If you just want to do some small tweaks on the default JSON,\nyou can call super first and make the tweaks on the returned\nJSON.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import RESTSerializer from '@ember-data/serializer/rest';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  serialize(snapshot, options) {\n    let json = super.serialize(snapshot, options);\n\n    json.subject = json.title;\n    delete json.title;\n\n    return json;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "json", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 650, + "description": "

You can use this method to customize the root keys serialized into the JSON.\nThe hash property should be modified by reference (possibly using something like _.extend)\nBy default the REST Serializer sends the modelName of a model, which is a camelized\nversion of the name.

\n

For example, your server may expect underscored root objects.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { decamelize } from '@ember/string';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  serializeIntoHash(data, type, record, options) {\n    let root = decamelize(type.modelName);\n    data[root] = this.serialize(record, options);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeIntoHash", + "access": "public", + "tagname": "", + "params": [ + { + "name": "hash", + "description": "", + "type": "Object" + }, + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 682, + "description": "

You can use payloadKeyFromModelName to override the root key for an outgoing\nrequest. By default, the RESTSerializer returns a camelized version of the\nmodel's name.

\n

For a model called TacoParty, its modelName would be the string taco-party. The RESTSerializer\nwill send it to the server with tacoParty as the root key in the JSON payload:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
{\n  "tacoParty": {\n    "id": "1",\n    "location": "Matthew Beale's House"\n  }\n}
\n
\n
\n \n

For example, your server may expect dasherized root objects:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { dasherize } from '@ember/string';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  payloadKeyFromModelName(modelName) {\n    return dasherize(modelName);\n  }\n}
\n
\n
\n \n

Given a TacoParty model, calling save on it would produce an outgoing\nrequest like:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
{\n  "taco-party": {\n    "id": "1",\n    "location": "Matthew Beale's House"\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "payloadKeyFromModelName", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 733, + "description": "

You can use this method to customize how polymorphic objects are serialized.\nBy default the REST Serializer creates the key by appending Type to\nthe attribute and value from the model's camelcased model name.

\n", + "itemtype": "method", + "name": "serializePolymorphicType", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/rest.js", + "line": 756, + "description": "

You can use this method to customize how a polymorphic relationship should\nbe extracted.

\n", + "itemtype": "method", + "name": "extractPolymorphicRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "relationshipType", + "description": "", + "type": "Object" + }, + { + "name": "relationshipHash", + "description": "", + "type": "Object" + }, + { + "name": "relationshipOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/rest" + }, + { + "file": "../serializer/addon/json.js", + "line": 182, + "description": "

Given a subclass of Model and a JSON object this method will\niterate through each attribute of the Model and invoke the\nTransform#deserialize method on the matching property of the\nJSON object. This method is typically called after the\nserializer's normalize method.

\n", + "itemtype": "method", + "name": "applyTransforms", + "access": "private", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "data", + "description": "The data to transform", + "type": "Object" + } + ], + "return": { + "description": "data The transformed data object", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 211, + "description": "

The normalizeResponse method is used to normalize a payload from the\nserver to a JSON-API Document.

\n

http://jsonapi.org/format/#document-structure

\n

This method delegates to a more specific normalize method based on\nthe requestType.

\n

To override this method with a custom one, make sure to call\nreturn this._super(store, primaryModelClass, payload, id, requestType) with your\npre-processed data.

\n

Here's an example of using normalizeResponse manually:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
socket.on('message', function(message) {\n  let data = message.data;\n  let modelClass = store.modelFor(data.modelName);\n  let serializer = store.serializerFor(data.modelName);\n  let normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id);\n\n  store.push(normalized);\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 272, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 290, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is queryRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeQueryRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 308, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findAll

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindAllResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 326, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findBelongsTo

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindBelongsToResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 344, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findHasMany

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindHasManyResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 362, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is findMany

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeFindManyResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 380, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is query

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeQueryResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 398, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is createRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeCreateRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 416, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is deleteRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeDeleteRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 434, + "description": "

Called by the default normalizeResponse implementation when the\ntype of request is updateRecord

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeUpdateRecordResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 452, + "description": "

normalizeUpdateRecordResponse, normalizeCreateRecordResponse and\nnormalizeDeleteRecordResponse delegate to this method by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeSaveResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 470, + "description": "

normalizeQueryResponse and normalizeFindRecordResponse delegate to this\nmethod by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeSingleResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 488, + "description": "

normalizeQueryResponse, normalizeFindManyResponse, and normalizeFindHasManyResponse delegate\nto this method by default.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeArrayResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 506, + "itemtype": "method", + "name": "_normalizeResponse", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + }, + { + "name": "isSingle", + "description": "", + "type": "Boolean" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "access": "private", + "tagname": "", + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 555, + "description": "

Normalizes a part of the JSON payload returned by\nthe server. You should override this method, munge the hash\nand call super if you have generic normalization to do.

\n

It takes the type of the record that is being normalized\n(as a Model class), the property where the hash was\noriginally found, and the hash to normalize.

\n

You can use this method, for example, to normalize underscored keys to camelized\nor other general-purpose normalizations.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\nimport { get } from '@ember/object';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  normalize(typeClass, hash) {\n    let fields = get(typeClass, 'fields');\n\n    fields.forEach(function(type, field) {\n      let payloadField = underscore(field);\n      if (field === payloadField) { return; }\n\n      hash[field] = hash[payloadField];\n      delete hash[payloadField];\n    });\n\n    return this._super.apply(this, arguments);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "hash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 619, + "description": "

Returns the resource's ID.

\n", + "itemtype": "method", + "name": "extractId", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 634, + "description": "

Returns the resource's attributes formatted as a JSON-API "attributes object".

\n

http://jsonapi.org/format/#document-resource-object-attributes

\n", + "itemtype": "method", + "name": "extractAttributes", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 659, + "description": "

Returns a relationship formatted as a JSON-API "relationship object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n", + "itemtype": "method", + "name": "extractRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "relationshipModelName", + "description": "", + "type": "Object" + }, + { + "name": "relationshipHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 694, + "description": "

Returns a polymorphic relationship formatted as a JSON-API "relationship object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n

relationshipOptions is a hash which contains more information about the\npolymorphic relationship which should be extracted:

\n
    \n
  • resourceHash complete hash of the resource the relationship should be\nextracted from
  • \n
  • relationshipKey key under which the value for the relationship is\nextracted from the resourceHash
  • \n
  • relationshipMeta meta information about the relationship
  • \n
\n", + "itemtype": "method", + "name": "extractPolymorphicRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "relationshipModelName", + "description": "", + "type": "Object" + }, + { + "name": "relationshipHash", + "description": "", + "type": "Object" + }, + { + "name": "relationshipOptions", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 718, + "description": "

Returns the resource's relationships formatted as a JSON-API "relationships object".

\n

http://jsonapi.org/format/#document-resource-object-relationships

\n", + "itemtype": "method", + "name": "extractRelationships", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelClass", + "description": "", + "type": "Object" + }, + { + "name": "resourceHash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 790, + "description": "

Dasherizes the model name in the payload

\n", + "itemtype": "method", + "name": "modelNameFromPayloadKey", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "the model's modelName", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 802, + "itemtype": "method", + "name": "normalizeRelationships", + "access": "private", + "tagname": "", + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 825, + "itemtype": "method", + "name": "normalizeUsingDeclaredMapping", + "access": "private", + "tagname": "", + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 858, + "description": "

Looks up the property key that was set by the custom attr mapping\npassed to the serializer.

\n", + "itemtype": "method", + "name": "_getMappedKey", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "key", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 897, + "description": "

Check attrs.key.serialize property to inform if the key\ncan be serialized

\n", + "itemtype": "method", + "name": "_canSerialize", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the key can be serialized", + "type": "Boolean" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 912, + "description": "

When attrs.key.serialize is set to true then\nit takes priority over the other checks and the related\nattribute/relationship will be serialized

\n", + "itemtype": "method", + "name": "_mustSerialize", + "access": "private", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the key must be serialized", + "type": "Boolean" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 928, + "description": "

Check if the given hasMany relationship should be serialized

\n

By default only many-to-many and many-to-none relationships are serialized.\nThis could be configured per relationship by Serializer's attrs object.

\n", + "itemtype": "method", + "name": "shouldSerializeHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "relationshipType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "true if the hasMany relationship should be serialized", + "type": "Boolean" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 950, + "description": "

Called when a record is saved in order to convert the\nrecord into JSON.

\n

By default, it creates a JSON object with a key for\neach attribute and belongsTo relationship.

\n

For example, consider this model:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n  @attr title;\n  @attr body;\n\n  @belongsTo('user') author;\n}
\n
\n
\n \n

The default serialization would create a JSON object like:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "title": "Rails is unagi",\n  "body": "Rails? Omakase? O_O",\n  "author": 12\n}
\n
\n
\n \n

By default, attributes are passed through as-is, unless\nyou specified an attribute type (attr('date')). If\nyou specify a transform, the JavaScript value will be\nserialized when inserted into the JSON hash.

\n

By default, belongs-to relationships are converted into\nIDs when inserted into the JSON hash.

\n

IDs

\n

serialize takes an options hash with a single option:\nincludeId. If this option is true, serialize will,\nby default include the ID in the JSON object it builds.

\n

The adapter passes in includeId: true when serializing\na record for createRecord, but not for updateRecord.

\n

Customization

\n

Your server may expect a different JSON format than the\nbuilt-in serialization format.

\n

In that case, you can implement serialize yourself and\nreturn a JSON hash of your choosing.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = {\n      POST_TTL: snapshot.attr('title'),\n      POST_BDY: snapshot.attr('body'),\n      POST_CMS: snapshot.hasMany('comments', { ids: true })\n    };\n\n    if (options.includeId) {\n      json.POST_ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}
\n
\n
\n \n

Customizing an App-Wide Serializer

\n

If you want to define a serializer for your entire\napplication, you'll probably want to use eachAttribute\nand eachRelationship on the record.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { singularize } from 'ember-inflector';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = {};\n\n    snapshot.eachAttribute((name) => {\n      json[serverAttributeName(name)] = snapshot.attr(name);\n    });\n\n    snapshot.eachRelationship((name, relationship) => {\n      if (relationship.kind === 'hasMany') {\n        json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n      }\n    });\n\n    if (options.includeId) {\n      json.ID_ = snapshot.id;\n    }\n\n    return json;\n  }\n}\n\nfunction serverAttributeName(attribute) {\n  return attribute.underscore().toUpperCase();\n}\n\nfunction serverHasManyName(name) {\n  return serverAttributeName(singularize(name)) + "_IDS";\n}
\n
\n
\n \n

This serializer will generate JSON that looks like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "TITLE": "Rails is omakase",\n  "BODY": "Yep. Omakase.",\n  "COMMENT_IDS": [ "1", "2", "3" ]\n}
\n
\n
\n \n

Tweaking the Default JSON

\n

If you just want to do some small tweaks on the default JSON,\nyou can call super.serialize first and make the tweaks on\nthe returned JSON.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serialize(snapshot, options) {\n    let json = super.serialize(...arguments);\n\n    json.subject = json.title;\n    delete json.title;\n\n    return json;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "json", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1128, + "description": "

You can use this method to customize how a serialized record is added to the complete\nJSON hash to be sent to the server. By default the JSON Serializer does not namespace\nthe payload and just sends the raw serialized JSON object.\nIf your server expects namespaced keys, you should consider using the RESTSerializer.\nOtherwise you can override this method to customize how the record is added to the hash.\nThe hash property should be modified by reference.

\n

For example, your server may expect underscored root objects.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { decamelize } from '@ember/string';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  serializeIntoHash(data, type, snapshot, options) {\n    let root = decamelize(type.modelName);\n    data[root] = this.serialize(snapshot, options);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeIntoHash", + "access": "public", + "tagname": "", + "params": [ + { + "name": "hash", + "description": "", + "type": "Object" + }, + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1161, + "description": "

serializeAttribute can be used to customize how attr\nproperties are serialized

\n

For example if you wanted to ensure all your attributes were always\nserialized as properties on an attributes object you could\nwrite:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  serializeAttribute(snapshot, json, key, attributes) {\n    json.attributes = json.attributes || {};\n    this._super(snapshot, json.attributes, key, attributes);\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "attribute", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1208, + "description": "

serializeBelongsTo can be used to customize how belongsTo\nproperties are serialized.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { isNone } from '@ember/utils';\n\nexport default class PostSerializer extends JSONSerializer {\n  serializeBelongsTo(snapshot, json, relationship) {\n    let key = relationship.key;\n    let belongsTo = snapshot.belongsTo(key);\n\n    key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key;\n\n    json[key] = isNone(belongsTo) ? belongsTo : belongsTo.record.toJSON();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeBelongsTo", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1262, + "description": "

serializeHasMany can be used to customize how hasMany\nproperties are serialized.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  serializeHasMany(snapshot, json, relationship) {\n    let key = relationship.key;\n    if (key === 'comments') {\n      return;\n    } else {\n      this._super(...arguments);\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializeHasMany", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1308, + "description": "

You can use this method to customize how polymorphic objects are\nserialized. Objects are considered to be polymorphic if\n{ polymorphic: true } is pass as the second argument to the\nbelongsTo function.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/comment.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { isNone } from '@ember/utils';\n\nexport default class CommentSerializer extends JSONSerializer {\n  serializePolymorphicType(snapshot, json, relationship) {\n    let key = relationship.key;\n    let belongsTo = snapshot.belongsTo(key);\n\n    key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key;\n\n    if (isNone(belongsTo)) {\n      json[key + '_type'] = null;\n    } else {\n      json[key + '_type'] = belongsTo.modelName;\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serializePolymorphicType", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "json", + "description": "", + "type": "Object" + }, + { + "name": "relationship", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1344, + "description": "

extractMeta is used to deserialize any meta information in the\nadapter payload. By default Ember Data expects meta information to\nbe located on the meta property of the payload object.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  extractMeta(store, typeClass, payload) {\n    if (payload && payload.hasOwnProperty('_pagination')) {\n      let meta = payload._pagination;\n      delete payload._pagination;\n      return meta;\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "extractMeta", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "modelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1379, + "description": "

extractErrors is used to extract model errors when a call\nto Model#save fails with an InvalidError. By default\nEmber Data expects error information to be located on the errors\nproperty of the payload object.

\n

This serializer expects this errors object to be an Array similar\nto the following, compliant with the https://jsonapi.org/format/#errors specification:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
{\n  "errors": [\n    {\n      "detail": "This username is already taken!",\n      "source": {\n        "pointer": "data/attributes/username"\n      }\n    }, {\n      "detail": "Doesn't look like a valid email.",\n      "source": {\n        "pointer": "data/attributes/email"\n      }\n    }\n  ]\n}
\n
\n
\n \n

The key detail provides a textual description of the problem.\nAlternatively, the key title can be used for the same purpose.

\n

The nested keys source.pointer detail which specific element\nof the request data was invalid.

\n

Note that JSON-API also allows for object-level errors to be placed\nin an object with pointer data, signifying that the problem\ncannot be traced to a specific attribute:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
{\n  "errors": [\n    {\n      "detail": "Some generic non property error message",\n      "source": {\n        "pointer": "data"\n      }\n    }\n  ]\n}
\n
\n
\n \n

When turn into a Errors object, you can read these errors\nthrough the property base:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{{#each @model.errors.base as |error|}}\n  <div class="error">\n    {{error.message}}\n  </div>\n{{/each}}
\n
\n
\n \n

Example of alternative implementation, overriding the default\nbehavior to deal with a different format of errors:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  extractErrors(store, typeClass, payload, id) {\n    if (payload && typeof payload === 'object' && payload._problems) {\n      payload = payload._problems;\n      this.normalizeErrors(typeClass, payload);\n    }\n    return payload;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "extractErrors", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "(String|Number)" + } + ], + "return": { + "description": "json The deserialized errors", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1491, + "description": "

keyForAttribute can be used to define rules for how to convert an\nattribute name in your model to a key in your JSON.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  keyForAttribute(attr, method) {\n    return underscore(attr).toUpperCase();\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1518, + "description": "

keyForRelationship can be used to define a custom key when\nserializing and deserializing relationship properties. By default\nJSONSerializer does not provide an implementation of this method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\nimport { underscore } from '@ember/string';\n\nexport default class PostSerializer extends JSONSerializer {\n  keyForRelationship(key, relationship, method) {\n    return `rel_${underscore(key)}`;\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "keyForRelationship", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "typeClass", + "description": "", + "type": "String" + }, + { + "name": "method", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1547, + "description": "

keyForLink can be used to define a custom key when deserializing link\nproperties.

\n", + "itemtype": "method", + "name": "keyForLink", + "access": "public", + "tagname": "", + "params": [ + { + "name": "key", + "description": "", + "type": "String" + }, + { + "name": "kind", + "description": "`belongsTo` or `hasMany`", + "type": "String" + } + ], + "return": { + "description": "normalized key", + "type": "String" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 1563, + "itemtype": "method", + "name": "transformFor", + "access": "private", + "tagname": "", + "params": [ + { + "name": "attributeType", + "description": "", + "type": "String" + }, + { + "name": "skipAssertion", + "description": "", + "type": "Boolean" + } + ], + "return": { + "description": "transform", + "type": "Transform" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 147, + "description": "

The normalizeResponse method is used to normalize a payload from the\nserver to a JSON-API Document.

\n

http://jsonapi.org/format/#document-structure

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
Serializer.extend({\n  normalizeResponse(store, primaryModelClass, payload, id, requestType) {\n    if (requestType === 'findRecord') {\n      return this.normalize(primaryModelClass, payload);\n    } else {\n      return payload.reduce(function(documentHash, item) {\n        let { data, included } = this.normalize(primaryModelClass, item);\n        documentHash.included.push(...included);\n        documentHash.data.push(data);\n        return documentHash;\n      }, { data: [], included: [] })\n    }\n  }\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "normalizeResponse", + "access": "public", + "tagname": "", + "params": [ + { + "name": "store", + "description": "", + "type": "Store" + }, + { + "name": "primaryModelClass", + "description": "", + "type": "Model" + }, + { + "name": "payload", + "description": "", + "type": "Object" + }, + { + "name": "id", + "description": "", + "type": "String|Number" + }, + { + "name": "requestType", + "description": "", + "type": "String" + } + ], + "return": { + "description": "JSON-API Document", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 184, + "description": "

The serialize method is used when a record is saved in order to convert\nthe record into the form that your external data source expects.

\n

serialize takes an optional options hash with a single option:

\n
    \n
  • includeId: If this is true, serialize should include the ID\nin the serialized object it builds.
  • \n
\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n
Serializer.extend({\n  serialize(snapshot, options) {\n    let json = {\n      id: snapshot.id\n    };\n\n    snapshot.eachAttribute((key, attribute) => {\n      json[key] = snapshot.attr(key);\n    });\n\n    snapshot.eachRelationship((key, relationship) => {\n      if (relationship.kind === 'belongsTo') {\n        json[key] = snapshot.belongsTo(key, { id: true });\n      } else if (relationship.kind === 'hasMany') {\n        json[key] = snapshot.hasMany(key, { ids: true });\n      }\n    });\n\n    return json;\n  },\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "snapshot", + "description": "", + "type": "Snapshot" + }, + { + "name": "options", + "description": "", + "type": "Object", + "optional": true + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 227, + "description": "

The normalize method is used to convert a payload received from your\nexternal data source into the normalized form store.push() expects. You\nshould override this method, munge the hash and return the normalized\npayload.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
Serializer.extend({\n  normalize(modelClass, resourceHash) {\n    let data = {\n      id:            resourceHash.id,\n      type:          modelClass.modelName,\n      attributes:    resourceHash\n    };\n    return { data: data };\n  }\n})
\n
\n
\n \n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "typeClass", + "description": "", + "type": "Model" + }, + { + "name": "hash", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "RESTSerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + } + ], + "events": [], + "properties": [ + { + "file": "../serializer/addon/json.js", + "line": 88, + "description": "

The primaryKey is used when serializing and deserializing\ndata. Ember Data always uses the id property to store the id of\nthe record. The external source may not always follow this\nconvention. In these cases it is useful to override the\nprimaryKey property to match the primaryKey of your external\nstore.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class ApplicationSerializer extends JSONSerializer {\n  primaryKey = '_id'\n}
\n
\n
\n \n", + "itemtype": "property", + "name": "primaryKey", + "type": "{String}", + "access": "public", + "tagname": "", + "default": "'id'", + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/json.js", + "line": 113, + "description": "

The attrs object can be used to declare a simple mapping between\nproperty names on Model records and payload keys in the\nserialized JSON object representing the record. An object with the\nproperty key can also be used to designate the attribute's key on\nthe response payload.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr } from '@ember-data/model';\n\nexport default class PersonModel extends Model {\n  @attr('string') firstName;\n  @attr('string') lastName;\n  @attr('string') occupation;\n  @attr('boolean') admin;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PersonSerializer extends JSONSerializer {\n  attrs = {\n    admin: 'is_admin',\n    occupation: { key: 'career' }\n  }\n}
\n
\n
\n \n

You can also remove attributes and relationships by setting the serialize\nkey to false in your mapping object.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default class PostSerializer extends JSONSerializer {\n  attrs = {\n    admin: { serialize: false },\n    occupation: { key: 'career' }\n  }\n}
\n
\n
\n \n

When serialized:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "firstName": "Harry",\n  "lastName": "Houdini",\n  "career": "magician"\n}
\n
\n
\n \n

Note that the admin is now not included in the payload.

\n

Setting serialize to true enforces serialization for hasMany\nrelationships even if it's neither a many-to-many nor many-to-none\nrelationship.

\n", + "itemtype": "property", + "name": "attrs", + "access": "public", + "tagname": "", + "type": "{Object}", + "class": "RESTSerializer", + "module": "@ember-data/serializer/json", + "inherited": true, + "inheritedFrom": "JSONSerializer" + }, + { + "file": "../serializer/addon/index.js", + "line": 125, + "description": "

The store property is the application's store that contains\nall records. It can be used to look up serializers for other model\ntypes that may be nested inside the payload response.

\n

Example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
Serializer.extend({\n  extractRelationship(relationshipModelName, relationshipHash) {\n    let modelClass = this.store.modelFor(relationshipModelName);\n    let relationshipSerializer = this.store.serializerFor(relationshipModelName);\n    return relationshipSerializer.normalize(modelClass, relationshipHash);\n  }\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "store", + "type": "{Store}", + "access": "public", + "tagname": "", + "class": "RESTSerializer", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Serializer" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-JSONSerializer", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer/rest", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RecordArray-3cdc3a8f26.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RecordArray-3cdc3a8f26.json new file mode 100644 index 000000000..fe790b312 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RecordArray-3cdc3a8f26.json @@ -0,0 +1,177 @@ +{ + "data": { + "id": "ember-data-3.28.13-RecordArray", + "type": "class", + "attributes": { + "name": "RecordArray", + "shortname": "RecordArray", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 19, + "description": "

A record array is an array that contains records of a certain modelName. The record\narray materializes records as needed when they are retrieved for the first\ntime. You should not create record arrays yourself. Instead, an instance of\nRecordArray or its subclasses will be returned by your application's store\nin response to queries.

\n

This class should not be imported and instantiated by consuming applications.

\n", + "access": "public", + "tagname": "", + "extends": "Ember.ArrayProxy", + "uses": [ + "Ember.Evented" + ], + "methods": [ + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 118, + "description": "

Retrieves an object from the content by index.

\n", + "itemtype": "method", + "name": "objectAtContent", + "access": "private", + "tagname": "", + "params": [ + { + "name": "index", + "description": "", + "type": "Number" + } + ], + "return": { + "description": "record", + "type": "Model" + }, + "class": "RecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 131, + "description": "

Used to get the latest version of all of the records in this array\nfrom the adapter.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
let people = store.peekAll('person');\npeople.get('isUpdating'); // false\n\npeople.update().then(function() {\n  people.get('isUpdating'); // false\n});\n\npeople.get('isUpdating'); // true
\n
\n
\n \n", + "itemtype": "method", + "name": "update", + "access": "public", + "tagname": "", + "class": "RecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 179, + "description": "

Saves all of the records in the RecordArray.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
let messages = store.peekAll('message');\nmessages.forEach(function(message) {\n  message.set('hasBeenSeen', true);\n});\nmessages.save();
\n
\n
\n \n", + "itemtype": "method", + "name": "save", + "access": "public", + "tagname": "", + "return": { + "description": "promise", + "type": "PromiseArray" + }, + "class": "RecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 230, + "itemtype": "method", + "name": "_createSnapshot", + "access": "private", + "tagname": "", + "class": "RecordArray", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [ + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 42, + "description": "

The array of client ids backing the record array. When a\nrecord is requested from the record array, the record\nfor the client id at the same index is materialized, if\nnecessary, by the store.

\n", + "itemtype": "property", + "name": "content", + "access": "private", + "tagname": "", + "type": "Ember.Array", + "class": "RecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 54, + "description": "

The flag to signal a RecordArray is finished loading data.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
let people = store.peekAll('person');\npeople.get('isLoaded'); // true
\n
\n
\n \n", + "itemtype": "property", + "name": "isLoaded", + "access": "public", + "tagname": "", + "type": "Boolean", + "class": "RecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 69, + "description": "

The flag to signal a RecordArray is currently loading data.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
let people = store.peekAll('person');\npeople.get('isUpdating'); // false\npeople.update();\npeople.get('isUpdating'); // true
\n
\n
\n \n", + "itemtype": "property", + "name": "isUpdating", + "access": "public", + "tagname": "", + "type": "Boolean", + "class": "RecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 87, + "description": "

The store that created this record array.

\n", + "itemtype": "property", + "name": "store", + "access": "private", + "tagname": "", + "type": "Store", + "class": "RecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/record-arrays/record-array.js", + "line": 104, + "description": "

The modelClass represented by this record array.

\n", + "itemtype": "property", + "name": "type", + "access": "public", + "tagname": "", + "type": "{subclass of Model}", + "class": "RecordArray", + "module": "@ember-data/store" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "Ember.ArrayProxy", + "type": "missing" + } + }, + "descendants": { + "data": [ + { + "type": "class", + "id": "ember-data-3.28.13-AdapterPopulatedRecordArray" + } + ] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RecordReference-6c446acafd.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RecordReference-6c446acafd.json new file mode 100644 index 000000000..645bbe6f0 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-RecordReference-6c446acafd.json @@ -0,0 +1,211 @@ +{ + "data": { + "id": "ember-data-3.28.13-RecordReference", + "type": "class", + "attributes": { + "name": "RecordReference", + "shortname": "RecordReference", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/references/record.ts", + "line": 22, + "description": "

A RecordReference is a low-level API that allows users and\naddon authors to perform meta-operations on a record.

\n", + "access": "public", + "tagname": "", + "extends": "Reference", + "methods": [ + { + "file": "../store/addon/-private/system/references/record.ts", + "line": 72, + "description": "

The id of the record that this reference refers to.

\n

Together, the type and id properties form a composite key for\nthe identity map.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
let userRef = store.getReference('user', 1);\n\nuserRef.id(); // '1'
\n
\n
\n \n", + "itemtype": "method", + "name": "id", + "access": "public", + "tagname": "", + "return": { + "description": "The id of the record.", + "type": "String" + }, + "class": "RecordReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/record.ts", + "line": 102, + "description": "

The identifier of the record that this reference refers to.

\n

Together, the type and id properties form a composite key for\nthe identity map.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
let userRef = store.getReference('user', 1);\n\nuserRef.identifier(); // '1'
\n
\n
\n \n", + "itemtype": "method", + "name": "identifier", + "access": "public", + "tagname": "", + "return": { + "description": "The identifier of the record.", + "type": "String" + }, + "class": "RecordReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/record.ts", + "line": 124, + "description": "

How the reference will be looked up when it is loaded. Currently\nthis always returns identity to signify that a record will be\nloaded by its type and id.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
const userRef = store.getReference('user', 1);\n\nuserRef.remoteType(); // 'identity'
\n
\n
\n \n", + "itemtype": "method", + "name": "remoteType", + "access": "public", + "tagname": "", + "return": { + "description": "'identity'", + "type": "String" + }, + "class": "RecordReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/record.ts", + "line": 145, + "description": "

This API allows you to provide a reference with new data. The\nsimplest usage of this API is similar to store.push: you provide a\nnormalized hash of data and the object represented by the reference\nwill update.

\n

If you pass a promise to push, Ember Data will not ask the adapter\nfor the data if another attempt to fetch it is made in the\ninterim. When the promise resolves, the underlying object is updated\nwith the new data, and the promise returned by this function is resolved\nwith that object.

\n

For example, recordReference.push(promise) will be resolved with a\nrecord.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
let userRef = store.getReference('user', 1);\n\n// provide data for reference\nuserRef.push({\n  data: {\n    id: "1",\n    type: "user",\n    attributes: {\n      username: "@user"\n    }\n  }\n}).then(function(user) {\n  userRef.value() === user;\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "push", + "access": "public", + "tagname": "", + "params": [ + { + "name": "objectOrPromise", + "description": "a JSON:API ResourceDocument or a promise resolving to one" + } + ], + "return": { + "description": "a promise for the value (record or relationship)" + }, + "class": "RecordReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/record.ts", + "line": 190, + "description": "

If the entity referred to by the reference is already loaded, it is\npresent as reference.value. Otherwise the value returned by this function\nis null.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
let userRef = store.getReference('user', 1);\n\nuserRef.value(); // user
\n
\n
\n \n", + "itemtype": "method", + "name": "value", + "access": "public", + "tagname": "", + "return": { + "description": "the record for this RecordReference", + "type": "Model" + }, + "class": "RecordReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/record.ts", + "line": 217, + "description": "

Triggers a fetch for the backing entity based on its remoteType\n(see remoteType definitions per reference type).

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
let userRef = store.getReference('user', 1);\n\n// load user (via store.find)\nuserRef.load().then(...)
\n
\n
\n \n", + "itemtype": "method", + "name": "load", + "access": "public", + "tagname": "", + "return": { + "description": "the record for this RecordReference", + "type": "Promise" + }, + "class": "RecordReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/record.ts", + "line": 242, + "description": "

Reloads the record if it is already loaded. If the record is not\nloaded it will load the record via store.findRecord

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
let userRef = store.getReference('user', 1);\n\n// or trigger a reload\nuserRef.reload().then(...)
\n
\n
\n \n", + "itemtype": "method", + "name": "reload", + "access": "public", + "tagname": "", + "return": { + "description": "the record for this RecordReference", + "type": "Promise" + }, + "class": "RecordReference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 61, + "description": "

This returns a string that represents how the reference will be\nlooked up when it is loaded. If the relationship has a link it will\nuse the "link" otherwise it defaults to "id".

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default Model.extend({\n  comments: hasMany({ async: true })\n});
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\n// get the identifier of the reference\nif (commentsRef.remoteType() === "ids") {\n  let ids = commentsRef.ids();\n} else if (commentsRef.remoteType() === "link") {\n  let link = commentsRef.link();\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "remoteType", + "access": "public", + "tagname": "", + "return": { + "description": "The name of the remote type. This should either be \"link\" or \"ids\"", + "type": "String" + }, + "class": "RecordReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 111, + "description": "

The link Ember Data will use to fetch or reload this belongs-to\nrelationship. By default it uses only the "related" resource linkage.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\nexport default Model.extend({\n   user: belongsTo({ async: true })\n });\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         links: {\n           related: '/articles/1/author'\n         }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\n// get the identifier of the reference\nif (userRef.remoteType() === "link") {\n   let link = userRef.link();\n }
\n
\n
\n \n", + "itemtype": "method", + "name": "link", + "access": "public", + "tagname": "", + "return": { + "description": "The link Ember Data will use to fetch or reload this belongs-to relationship.", + "type": "String" + }, + "class": "RecordReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 168, + "description": "

The meta data for the belongs-to relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\nexport default Model.extend({\n   user: belongsTo({ async: true })\n });\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         links: {\n           related: {\n             href: '/articles/1/author'\n           },\n           meta: {\n             lastUpdated: 1458014400000\n           }\n         }\n       }\n     }\n   }\n });\n\nlet userRef = blog.belongsTo('user');\n\nuserRef.meta() // { lastUpdated: 1458014400000 }
\n
\n
\n \n", + "itemtype": "method", + "name": "meta", + "access": "public", + "tagname": "", + "return": { + "description": "The meta information for the belongs-to relationship.", + "type": "Object" + }, + "class": "RecordReference", + "module": "@ember-data/store", + "inherited": true, + "inheritedFrom": "Reference" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Reference", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Reference-125917c3ed.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Reference-125917c3ed.json new file mode 100644 index 000000000..fbda66349 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Reference-125917c3ed.json @@ -0,0 +1,104 @@ +{ + "data": { + "id": "ember-data-3.28.13-Reference", + "type": "class", + "attributes": { + "name": "Reference", + "shortname": "Reference", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/references/reference.ts", + "line": 40, + "description": "

This is the baseClass for the different References\nlike RecordReference/HasManyReference/BelongsToReference

\n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 61, + "description": "

This returns a string that represents how the reference will be\nlooked up when it is loaded. If the relationship has a link it will\nuse the "link" otherwise it defaults to "id".

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n
import Model, { hasMany } from '@ember-data/model';\n\nexport default Model.extend({\n  comments: hasMany({ async: true })\n});
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n
let post = store.push({\n  data: {\n    type: 'post',\n    id: 1,\n    relationships: {\n      comments: {\n        data: [{ type: 'comment', id: 1 }]\n      }\n    }\n  }\n});\n\nlet commentsRef = post.hasMany('comments');\n\n// get the identifier of the reference\nif (commentsRef.remoteType() === "ids") {\n  let ids = commentsRef.ids();\n} else if (commentsRef.remoteType() === "link") {\n  let link = commentsRef.link();\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "remoteType", + "access": "public", + "tagname": "", + "return": { + "description": "The name of the remote type. This should either be \"link\" or \"ids\"", + "type": "String" + }, + "class": "Reference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 111, + "description": "

The link Ember Data will use to fetch or reload this belongs-to\nrelationship. By default it uses only the "related" resource linkage.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\nexport default Model.extend({\n   user: belongsTo({ async: true })\n });\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         links: {\n           related: '/articles/1/author'\n         }\n       }\n     }\n   }\n });\nlet userRef = blog.belongsTo('user');\n\n// get the identifier of the reference\nif (userRef.remoteType() === "link") {\n   let link = userRef.link();\n }
\n
\n
\n \n", + "itemtype": "method", + "name": "link", + "access": "public", + "tagname": "", + "return": { + "description": "The link Ember Data will use to fetch or reload this belongs-to relationship.", + "type": "String" + }, + "class": "Reference", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/references/reference.ts", + "line": 168, + "description": "

The meta data for the belongs-to relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n
// models/blog.js\nimport Model, { belongsTo } from '@ember-data/model';\nexport default Model.extend({\n   user: belongsTo({ async: true })\n });\n\nlet blog = store.push({\n   data: {\n     type: 'blog',\n     id: 1,\n     relationships: {\n       user: {\n         links: {\n           related: {\n             href: '/articles/1/author'\n           },\n           meta: {\n             lastUpdated: 1458014400000\n           }\n         }\n       }\n     }\n   }\n });\n\nlet userRef = blog.belongsTo('user');\n\nuserRef.meta() // { lastUpdated: 1458014400000 }
\n
\n
\n \n", + "itemtype": "method", + "name": "meta", + "access": "public", + "tagname": "", + "return": { + "description": "The meta information for the belongs-to relationship.", + "type": "Object" + }, + "class": "Reference", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [ + { + "type": "class", + "id": "ember-data-3.28.13-BelongsToReference" + }, + { + "type": "class", + "id": "ember-data-3.28.13-HasManyReference" + }, + { + "type": "class", + "id": "ember-data-3.28.13-RecordReference" + } + ] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Snapshot-a430655fd4.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Snapshot-a430655fd4.json new file mode 100644 index 000000000..f9c4ab9a1 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Snapshot-a430655fd4.json @@ -0,0 +1,322 @@ +{ + "data": { + "id": "ember-data-3.28.13-Snapshot", + "type": "class", + "attributes": { + "name": "Snapshot", + "shortname": "Snapshot", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/snapshot.ts", + "line": 36, + "description": "

Snapshot is not directly instantiable.\nInstances are provided to a consuming application's\nadapters and serializers for certain requests.

\n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 59, + "itemtype": "method", + "name": "constructor", + "is_constructor": 1, + "access": "private", + "tagname": "", + "params": [ + { + "name": "options", + "description": "" + }, + { + "name": "identifier", + "description": "" + }, + { + "name": "_store", + "description": "" + } + ], + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 199, + "description": "

Returns the value of an attribute.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\npostSnapshot.attr('author'); // => 'Tomster'\npostSnapshot.attr('title'); // => 'Ember.js rocks'
\n
\n
\n \n

Note: Values are loaded eagerly and cached when the snapshot is created.

\n", + "itemtype": "method", + "name": "attr", + "params": [ + { + "name": "keyName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "The attribute value or undefined", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 224, + "description": "

Returns all attributes and their corresponding values.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\npostSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
\n
\n
\n \n", + "itemtype": "method", + "name": "attributes", + "return": { + "description": "All attributes of the current snapshot", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 242, + "description": "

Returns all changed attributes and their old and new values.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\npostModel.set('title', 'Ember.js rocks!');\npostSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
\n
\n
\n \n", + "itemtype": "method", + "name": "changedAttributes", + "return": { + "description": "All changed attributes of the current snapshot", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 273, + "description": "

Returns the current value of a belongsTo relationship.

\n

belongsTo takes an optional hash of options as a second parameter,\ncurrently supported options are:

\n
    \n
  • id: set to true if you only want the ID of the related record to be\nreturned.
  • \n
\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
// store.push('post', { id: 1, title: 'Hello World' });\n// store.createRecord('comment', { body: 'Lorem ipsum', post: post });\ncommentSnapshot.belongsTo('post'); // => Snapshot\ncommentSnapshot.belongsTo('post', { id: true }); // => '1'\n\n// store.push('comment', { id: 1, body: 'Lorem ipsum' });\ncommentSnapshot.belongsTo('post'); // => undefined
\n
\n
\n \n

Calling belongsTo will return a new Snapshot as long as there's any known\ndata for the relationship available, such as an ID. If the relationship is\nknown but unset, belongsTo will return null. If the contents of the\nrelationship is unknown belongsTo will return undefined.

\n

Note: Relationships are loaded lazily and cached upon first access.

\n", + "itemtype": "method", + "name": "belongsTo", + "params": [ + { + "name": "keyName", + "description": "", + "type": "String" + }, + { + "name": "options", + "description": "", + "type": "Object", + "optional": true + } + ], + "access": "public", + "tagname": "", + "return": { + "description": "A snapshot or ID of a known\nrelationship or null if the relationship is known but unset. undefined\nwill be returned if the contents of the relationship is unknown.", + "type": "(Snapshot|String|null|undefined)" + }, + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 377, + "description": "

Returns the current value of a hasMany relationship.

\n

hasMany takes an optional hash of options as a second parameter,\ncurrently supported options are:

\n
    \n
  • ids: set to true if you only want the IDs of the related records to be\nreturned.
  • \n
\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
// store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });\npostSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]\npostSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']\n\n// store.push('post', { id: 1, title: 'Hello World' });\npostSnapshot.hasMany('comments'); // => undefined
\n
\n
\n \n

Note: Relationships are loaded lazily and cached upon first access.

\n", + "itemtype": "method", + "name": "hasMany", + "params": [ + { + "name": "keyName", + "description": "", + "type": "String" + }, + { + "name": "options", + "description": "", + "type": "Object", + "optional": true + } + ], + "access": "public", + "tagname": "", + "return": { + "description": "An array of snapshots or IDs of a known\nrelationship or an empty array if the relationship is known but unset.\nundefined will be returned if the contents of the relationship is unknown.", + "type": "(Array|undefined)" + }, + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 476, + "description": "

Iterates through all the attributes of the model, calling the passed\nfunction on each attribute.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
snapshot.eachAttribute(function(name, meta) {\n  // ...\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "eachAttribute", + "params": [ + { + "name": "callback", + "description": "the callback to execute", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Object", + "optional": true + } + ], + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 505, + "description": "

Iterates through all the relationships of the model, calling the passed\nfunction on each relationship.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
snapshot.eachRelationship(function(name, relationship) {\n  // ...\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "eachRelationship", + "params": [ + { + "name": "callback", + "description": "the callback to execute", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Object", + "optional": true + } + ], + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 534, + "description": "

Serializes the snapshot using the serializer for the model.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import Adapter from '@ember-data/adapter';\n\nexport default Adapter.extend({\n  createRecord(store, type, snapshot) {\n    let data = snapshot.serialize({ includeId: true });\n    let url = `/${type.modelName}`;\n\n    return fetch(url, {\n      method: 'POST',\n      body: data,\n    }).then((response) => response.json())\n  }\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "params": [ + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "an object whose values are primitive JSON values only", + "type": "Object" + }, + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [ + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 86, + "description": "

The id of the snapshot's underlying record

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\npostSnapshot.id; // => '1'
\n
\n
\n \n", + "itemtype": "property", + "name": "id", + "type": "{String}", + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 102, + "description": "

A hash of adapter options

\n", + "itemtype": "property", + "name": "adapterOptions", + "type": "{Object}", + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 110, + "description": "

If include was passed to the options hash for the request, the value\nwould be available here.

\n", + "itemtype": "property", + "name": "include", + "type": "{String|Array}", + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 120, + "description": "

The name of the type of the underlying record for this snapshot, as a string.

\n", + "itemtype": "property", + "name": "modelName", + "type": "{String}", + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 133, + "description": "

The underlying record for this snapshot. Can be used to access methods and\nproperties defined on the record.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
let json = snapshot.record.toJSON();
\n
\n
\n \n", + "itemtype": "property", + "name": "record", + "type": "{Model}", + "access": "public", + "tagname": "", + "class": "Snapshot", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot.ts", + "line": 181, + "description": "

The type of the underlying record for this snapshot, as a Model.

\n", + "itemtype": "property", + "name": "type", + "access": "public", + "tagname": "", + "type": "{Model}", + "class": "Snapshot", + "module": "@ember-data/store" + } + ] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-SnapshotRecordArray-d7fdb43022.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-SnapshotRecordArray-d7fdb43022.json new file mode 100644 index 000000000..e9b0c5095 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-SnapshotRecordArray-d7fdb43022.json @@ -0,0 +1,186 @@ +{ + "data": { + "id": "ember-data-3.28.13-SnapshotRecordArray", + "type": "class", + "attributes": { + "name": "SnapshotRecordArray", + "shortname": "SnapshotRecordArray", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 8, + "description": "

SnapshotRecordArray is not directly instantiable.\nInstances are provided to consuming application's\nadapters for certain requests.

\n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 26, + "description": "

SnapshotRecordArray is not directly instantiable.\nInstances are provided to consuming application's\nadapters and serializers for certain requests.

\n", + "itemtype": "method", + "name": "constructor", + "access": "private", + "tagname": "", + "is_constructor": 1, + "params": [ + { + "name": "recordArray", + "description": "", + "type": "RecordArray" + }, + { + "name": "meta", + "description": "", + "type": "Object" + }, + { + "name": "options", + "description": "" + } + ], + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 168, + "description": "

Get snapshots of the underlying record array

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class PostAdapter extends JSONAPIAdapter {\n  shouldReloadAll(store, snapshotArray) {\n    let snapshots = snapshotArray.snapshots();\n\n    return snapshots.any(function(ticketSnapshot) {\n      let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');\n      if (timeDiff > 20) {\n        return true;\n      } else {\n        return false;\n      }\n    });\n  }\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "snapshots", + "access": "public", + "tagname": "", + "return": { + "description": "Array of snapshots", + "type": "Array" + }, + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [ + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 39, + "description": "

An array of snapshots

\n", + "access": "private", + "tagname": "", + "itemtype": "property", + "name": "_snapshots", + "type": "{Array}", + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 47, + "description": "

An array of records

\n", + "access": "private", + "tagname": "", + "itemtype": "property", + "name": "_recordArray", + "type": "{Array}", + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 55, + "description": "

Number of records in the array

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class PostAdapter extends JSONAPIAdapter {\n  shouldReloadAll(store, snapshotRecordArray) {\n    return !snapshotRecordArray.length;\n  }\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "length", + "access": "public", + "tagname": "", + "type": "{Number}", + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 78, + "description": "

Meta objects for the record array.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class PostAdapter extends JSONAPIAdapter {\n  shouldReloadAll(store, snapshotRecordArray) {\n    let lastRequestTime = snapshotRecordArray.meta.lastRequestTime;\n    let twentyMinutes = 20 * 60 * 1000;\n    return Date.now() > lastRequestTime + twentyMinutes;\n  }\n});
\n
\n
\n \n", + "itemtype": "property", + "name": "meta", + "access": "public", + "tagname": "", + "type": "{Object}", + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 101, + "description": "

A hash of adapter options passed into the store method for this request.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import MyCustomAdapter from './custom-adapter';\n\nexport default class PostAdapter extends MyCustomAdapter {\n  findAll(store, type, sinceToken, snapshotRecordArray) {\n    if (snapshotRecordArray.adapterOptions.subscribe) {\n      // ...\n    }\n    // ...\n  }\n}
\n
\n
\n \n", + "itemtype": "property", + "name": "adapterOptions", + "access": "public", + "tagname": "", + "type": "{Object}", + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 125, + "description": "

The relationships to include for this request.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import Adapter from '@ember-data/adapter';\n\nexport default class ApplicationAdapter extends Adapter {\n  findAll(store, type, snapshotRecordArray) {\n    let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;\n\n    return fetch(url).then((response) => response.json())\n  }\n}
\n
\n
\n \n", + "itemtype": "property", + "name": "include", + "access": "public", + "tagname": "", + "type": "{String|Array}", + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 149, + "description": "

The type of the underlying records for the snapshots in the array, as a Model

\n", + "itemtype": "property", + "name": "type", + "access": "public", + "tagname": "", + "type": "{Model}", + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/snapshot-record-array.ts", + "line": 158, + "description": "

The modelName of the underlying records for the snapshots in the array, as a Model

\n", + "itemtype": "property", + "name": "modelName", + "access": "public", + "tagname": "", + "type": "{Model}", + "class": "SnapshotRecordArray", + "module": "@ember-data/store" + } + ] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Store-cadfb8849f.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Store-cadfb8849f.json new file mode 100644 index 000000000..63d3f91ce --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Store-cadfb8849f.json @@ -0,0 +1,1076 @@ +{ + "data": { + "id": "ember-data-3.28.13-Store", + "type": "class", + "attributes": { + "name": "Store", + "shortname": "Store", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/store", + "namespace": "", + "file": "../store/addon/-private/system/core-store.ts", + "line": 149, + "description": "

The store contains all of the data for records loaded from the server.\nIt is also responsible for creating instances of Model that wrap\nthe individual data for a record, so that they can be bound to in your\nHandlebars templates.

\n

Define your application's store like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/services/store.js
1\n2\n3\n
import Store from '@ember-data/store';\n\nexport default class MyStore extends Store {}
\n
\n
\n \n

Most Ember.js applications will only have a single Store that is\nautomatically created by their Ember.Application.

\n

You can retrieve models from the store in several ways. To retrieve a record\nfor a specific id, use Store's findRecord() method:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.findRecord('person', 123).then(function (person) {\n});
\n
\n
\n \n

By default, the store will talk to your backend using a standard\nREST mechanism. You can customize how the store talks to your\nbackend by specifying a custom adapter:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n
import Adapter from '@ember-data/adapter';\n\nexport default class ApplicationAdapter extends Adapter {\n}
\n
\n
\n \n

You can learn more about writing a custom adapter by reading the Adapter\ndocumentation.

\n

Store createRecord() vs. push() vs. pushPayload()

\n

The store provides multiple ways to create new record objects. They have\nsome subtle differences in their use which are detailed below:

\n

createRecord is used for creating new\nrecords on the client side. This will return a new record in the\ncreated.uncommitted state. In order to persist this record to the\nbackend, you will need to call record.save().

\n

push is used to notify Ember Data's store of new or\nupdated records that exist in the backend. This will return a record\nin the loaded.saved state. The primary use-case for store#push is\nto notify Ember Data about record updates (full or partial) that happen\noutside of the normal adapter methods (for example\nSSE or Web\nSockets).

\n

pushPayload is a convenience wrapper for\nstore#push that will deserialize payloads if the\nSerializer implements a pushPayload method.

\n

Note: When creating a new record using any of the above methods\nEmber Data will update RecordArrays such as those returned by\nstore#peekAll() or store#findAll(). This means any\ndata bindings or computed properties that depend on the RecordArray\nwill automatically be synced to include the new or updated record\nvalues.\n @mainName @ember-data/store\n @tag main

\n", + "_main": true, + "access": "public", + "tagname": "", + "extends": "Ember.Service", + "methods": [ + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 307, + "itemtype": "method", + "name": "init", + "access": "private", + "tagname": "", + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 547, + "description": "

Returns the schema for a particular modelName.

\n

When used with Model from @ember-data/model the return is the model class,\nbut this is not guaranteed.

\n

The class of a model might be useful if you want to get a list of all the\nrelationship names of the model, see\nrelationshipNames\nfor example.

\n", + "itemtype": "method", + "name": "modelFor", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "Subclass of Model | ShimModelClass" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 572, + "description": "

Returns whether a ModelClass exists for a given modelName\nThis exists for legacy support for the RESTSerializer,\nwhich due to how it must guess whether a key is a model\nmust query for whether a match exists.

\n

We should investigate an RFC to make this public or removing\nthis requirement.

\n", + "itemtype": "method", + "name": "_hasModelFor", + "access": "private", + "tagname": "", + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 598, + "description": "

Create a new record in the current store. The properties passed\nto this method are set on the newly created record.

\n

To create a new instance of a Post:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
store.createRecord('post', {\n  title: 'Ember is awesome!'\n});
\n
\n
\n \n

To create a new instance of a Post that has a relationship with a User record:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
let user = this.store.peekRecord('user', 1);\nstore.createRecord('post', {\n  title: 'Ember is awesome!',\n  user: user\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "createRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "inputProperties", + "description": "a hash of properties to set on the\n newly created record.", + "type": "Object" + } + ], + "return": { + "description": "record", + "type": "Model" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 671, + "description": "

If possible, this method asks the adapter to generate an ID for\na newly created record.

\n", + "itemtype": "method", + "name": "_generateId", + "access": "private", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "properties", + "description": "from the new record", + "type": "Object" + } + ], + "return": { + "description": "if the adapter can generate one, an ID", + "type": "String" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 695, + "description": "

For symmetry, a record can be deleted via the store.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
let post = store.createRecord('post', {\n  title: 'Ember is awesome!'\n});\n\nstore.deleteRecord(post);
\n
\n
\n \n", + "itemtype": "method", + "name": "deleteRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "record", + "description": "", + "type": "Model" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 746, + "description": "

For symmetry, a record can be unloaded via the store.\nThis will cause the record to be destroyed and freed up for garbage collection.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
store.findRecord('post', 1).then(function(post) {\n  store.unloadRecord(post);\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "unloadRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "record", + "description": "", + "type": "Model" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 798, + "itemtype": "method", + "name": "find", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "String|Integer" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "access": "private", + "tagname": "", + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 838, + "description": "

This method returns a record for a given type and id combination.

\n

The findRecord method will always resolve its promise with the same\nobject for a given type and id.

\n

The findRecord method will always return a promise that will be\nresolved with the record.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post.js
1\n2\n3\n4\n5\n6\n7\n
import Route from '@ember/routing/route';\n\nexport default class PostRoute extends Route {\n  model(params) {\n    return this.store.findRecord('post', params.post_id);\n  }\n}
\n
\n
\n \n

If the record is not yet available, the store will ask the adapter's find\nmethod to find the necessary data. If the record is already present in the\nstore, it depends on the reload behavior when the returned promise\nresolves.

\n

Preloading

\n

You can optionally preload specific attributes and relationships that you know of\nby passing them via the passed options.

\n

For example, if your Ember route looks like /posts/1/comments/2 and your API route\nfor the comment also looks like /posts/1/comments/2 if you want to fetch the comment\nwithout fetching the post you can pass in the post to the findRecord call:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.findRecord('comment', 2, { preload: { post: 1 } });
\n
\n
\n \n

If you have access to the post model you can also pass the model itself:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
store.findRecord('post', 1).then(function (myPostModel) {\n  store.findRecord('comment', 2, { post: myPostModel });\n});
\n
\n
\n \n

Reloading

\n

The reload behavior is configured either via the passed options hash or\nthe result of the adapter's shouldReloadRecord.

\n

If { reload: true } is passed or adapter.shouldReloadRecord evaluates\nto true, then the returned promise resolves once the adapter returns\ndata, regardless if the requested record is already in the store:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n
store.push({\n  data: {\n    id: 1,\n    type: 'post',\n    revision: 1\n  }\n});\n\n// adapter#findRecord resolves with\n// [\n//   {\n//     id: 1,\n//     type: 'post',\n//     revision: 2\n//   }\n// ]\nstore.findRecord('post', 1, { reload: true }).then(function(post) {\n  post.get('revision'); // 2\n});
\n
\n
\n \n

If no reload is indicated via the above mentioned ways, then the promise\nimmediately resolves with the cached version in the store.

\n

Background Reloading

\n

Optionally, if adapter.shouldBackgroundReloadRecord evaluates to true,\nthen a background reload is started, which updates the records' data, once\nit is available:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n
// app/adapters/post.js\nimport ApplicationAdapter from "./application";\n\nexport default class PostAdapter extends ApplicationAdapter {\n  shouldReloadRecord(store, snapshot) {\n    return false;\n  },\n\n  shouldBackgroundReloadRecord(store, snapshot) {\n    return true;\n  }\n});\n\n// ...\n\nstore.push({\n  data: {\n    id: 1,\n    type: 'post',\n    revision: 1\n  }\n});\n\nlet blogPost = store.findRecord('post', 1).then(function(post) {\n  post.get('revision'); // 1\n});\n\n// later, once adapter#findRecord resolved with\n// [\n//   {\n//     id: 1,\n//     type: 'post',\n//     revision: 2\n//   }\n// ]\n\nblogPost.get('revision'); // 2
\n
\n
\n \n

If you would like to force or prevent background reloading, you can set a\nboolean value for backgroundReload in the options object for\nfindRecord.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post/edit.js
1\n2\n3\n4\n5\n6\n7\n
import Route from '@ember/routing/route';\n\nexport default class PostEditRoute extends Route {\n  model(params) {\n    return this.store.findRecord('post', params.post_id, { backgroundReload: false });\n  }\n}
\n
\n
\n \n

If you pass an object on the adapterOptions property of the options\nargument it will be passed to your adapter via the snapshot

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post/edit.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import Route from '@ember/routing/route';\n\nexport default class PostEditRoute extends Route {\n  model(params) {\n    return this.store.findRecord('post', params.post_id, {\n      adapterOptions: { subscribe: false }\n    });\n  }\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import MyCustomAdapter from './custom-adapter';\n\nexport default class PostAdapter extends MyCustomAdapter {\n  findRecord(store, type, id, snapshot) {\n    if (snapshot.adapterOptions.subscribe) {\n      // ...\n    }\n    // ...\n  }\n}
\n
\n
\n \n

See peekRecord to get the cached version of a record.

\n\n

If you use an adapter such as Ember's default\nJSONAPIAdapter\nthat supports the JSON API specification and if your server\nendpoint supports the use of an\n'include' query parameter,\nyou can use findRecord() or findAll() to automatically retrieve additional records related to\nthe one you request by supplying an include parameter in the options object.

\n

For example, given a post model that has a hasMany relationship with a comment\nmodel, when we retrieve a specific post we can have the server also return that post's\ncomments in the same request:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post.js
1\n2\n3\n4\n5\n6\n7\n
import Route from '@ember/routing/route';\n\nexport default class PostRoute extends Route {\n  model(params) {\n    return this.store.findRecord('post', params.post_id, { include: 'comments' });\n  }\n}
\n
\n
\n \n

In this case, the post's comments would then be available in your template as\nmodel.comments.

\n

Multiple relationships can be requested using an include parameter consisting of a\ncomma-separated list (without white-space) while nested relationships can be specified\nusing a dot-separated sequence of relationship names. So to request both the post's\ncomments and the authors of those comments the request would look like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post.js
1\n2\n3\n4\n5\n6\n7\n
import Route from '@ember/routing/route';\n\nexport default class PostRoute extends Route {\n  model(params) {\n    return this.store.findRecord('post', params.post_id, { include: 'comments,comments.author' });\n  }\n}
\n
\n
\n \n

Retrieving Specific Fields by Type

\n

If your server endpoint supports the use of a 'fields' query parameter,\nyou can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part.

\n
    \n
  1. Implement buildQuery in your adapter.
  2. \n
\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
buildQuery(snapshot) {\n  let query = this._super(...arguments);\n\n  let { fields } = snapshot.adapterOptions;\n\n  if (fields) {\n    query.fields = fields;\n  }\n\n  return query;\n}
\n
\n
\n \n
    \n
  1. Then pass through the applicable fields to your findRecord request.
  2. \n
\n

Given a post model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post.js
1\n2\n3\n4\n5\n6\n
import Route from '@ember/routing/route';\nexport default Route.extend({\n  model(params) {\n    return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } });\n  }\n});
\n
\n
\n \n

Moreover, you can filter attributes on related models as well. If a post has a belongsTo relationship to a user,\njust include the relationship key and attributes.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post.js
1\n2\n3\n4\n5\n6\n
import Route from '@ember/routing/route';\nexport default Route.extend({\n  model(params) {\n    return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } });\n  }\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "findRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "(String|Integer)" + }, + { + "name": "options", + "description": "", + "type": "Object", + "optional": true + }, + { + "name": "preload", + "description": "- optional set of attributes and relationships passed in either as IDs or as actual models", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1204, + "description": "

This method makes a series of requests to the adapter's find method\nand returns a promise that resolves once they are all loaded.

\n", + "access": "private", + "tagname": "", + "itemtype": "method", + "name": "findByIds", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "ids", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1235, + "description": "

This method is called by findRecord if it discovers that a particular\ntype/id pair hasn't been loaded yet to kick off a request to the\nadapter.

\n", + "itemtype": "method", + "name": "_fetchRecord", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModel", + "description": "model", + "type": "InternalModel" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1526, + "description": "

Get the reference for the specified record.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n
let userRef = store.getReference('user', 1);\n\n// check if the user is loaded\nlet isLoaded = userRef.value() !== null;\n\n// get the record of the reference (null if not yet available)\nlet user = userRef.value();\n\n// get the identifier of the reference\nif (userRef.remoteType() === 'id') {\nlet id = userRef.id();\n}\n\n// load user (via store.find)\nuserRef.load().then(...)\n\n// or trigger a reload\nuserRef.reload().then(...)\n\n// provide data for reference\nuserRef.push({ id: 1, username: '@user' }).then(function(user) {\n  userRef.value() === user;\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "getReference", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "String|Integer" + } + ], + "since": "2.5.0", + "return": { + "description": "", + "type": "RecordReference" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1584, + "description": "

Get a record by a given type and ID without triggering a fetch.

\n

This method will synchronously return the record if it is available in the store,\notherwise it will return null. A record is available if it has been fetched earlier, or\npushed manually into the store.

\n

See findRecord if you would like to request this record from the backend.

\n

Note: This is a synchronous method and does not return a promise.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
let post = store.peekRecord('post', 1);\n\npost.get('id'); // 1
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "peekRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "String|Integer" + } + ], + "return": { + "description": "record", + "type": "Model|null" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1628, + "description": "

This method is called by the record's reload method.

\n

This method calls the adapter's find method, which returns a promise. When\nthat promise resolves, _reloadRecord will resolve the promise returned\nby the record's reload.

\n", + "itemtype": "method", + "name": "_reloadRecord", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModel", + "description": "", + "type": "Model" + }, + { + "name": "options", + "description": "optional to include adapterOptions" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1658, + "description": "

This method returns true if a record for a given modelName and id is already\nloaded in the store. Use this function to know beforehand if a findRecord()\nwill result in a request or that it will be a cache hit.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
store.hasRecordForId('post', 1); // false\nstore.findRecord('post', 1).then(function() {\n  store.hasRecordForId('post', 1); // true\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "hasRecordForId", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "(String|Integer)" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1698, + "description": "

Returns id record for a given type and ID. If one isn't already loaded,\nit builds a new record and leaves it in the empty state.

\n", + "itemtype": "method", + "name": "recordForId", + "access": "private", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "id", + "description": "", + "type": "(String|Integer)" + } + ], + "return": { + "description": "record", + "type": "Model" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1723, + "itemtype": "method", + "name": "findMany", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModels", + "description": "", + "type": "Array" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1742, + "description": "

If a relationship was originally populated by the adapter as a link\n(as opposed to a list of IDs), this method is called when the\nrelationship is fetched.

\n

The link (which is usually a URL) is passed through unchanged, so the\nadapter can make whatever request it wants.

\n

The usual use-case is for the server to register a URL as a link, and\nthen use that URL in the future to make a request for the relationship.

\n", + "itemtype": "method", + "name": "findHasMany", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModel", + "description": "", + "type": "InternalModel" + }, + { + "name": "link", + "description": "", + "type": "Any" + }, + { + "name": "relationship", + "description": "", + "type": "(Relationship)" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1836, + "itemtype": "method", + "name": "findBelongsTo", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModel", + "description": "", + "type": "InternalModel" + }, + { + "name": "link", + "description": "", + "type": "Any" + }, + { + "name": "relationship", + "description": "", + "type": "Relationship" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 1949, + "description": "

This method delegates a query to the adapter. This is the one place where\nadapter-level semantics are exposed to the application.

\n

Each time this method is called a new request is made through the adapter.

\n

Exposing queries this way seems preferable to creating an abstract query\nlanguage for all server-side queries, and then require all adapters to\nimplement them.

\n
\n

If you do something like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.query('person', { page: 1 });
\n
\n
\n \n

The request made to the server will look something like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
GET "/api/v1/person?page=1"
\n
\n
\n \n
\n

If you do something like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.query('person', { ids: [1, 2, 3] });
\n
\n
\n \n

The request made to the server will look something like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
GET "/api/v1/person?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3"\ndecoded: "/api/v1/person?ids[]=1&ids[]=2&ids[]=3"
\n
\n
\n \n

This method returns a promise, which is resolved with an\nAdapterPopulatedRecordArray\nonce the server returns.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "query", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "query", + "description": "an opaque query to be used by the adapter", + "type": "Any" + }, + { + "name": "options", + "description": "optional, may include `adapterOptions` hash which will be passed to adapter.query", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2040, + "description": "

This method makes a request for one record, where the id is not known\nbeforehand (if the id is known, use findRecord\ninstead).

\n

This method can be used when it is certain that the server will return a\nsingle object for the primary data.

\n

Each time this method is called a new request is made through the adapter.

\n

Let's assume our API provides an endpoint for the currently logged in user\nvia:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
// GET /api/current_user\n{\n  user: {\n    id: 1234,\n    username: 'admin'\n  }\n}
\n
\n
\n \n

Since the specific id of the user is not known beforehand, we can use\nqueryRecord to get the user:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
store.queryRecord('user', {}).then(function(user) {\n  let username = user.get('username');\n  console.log(`Currently logged in as ${username}`);\n});
\n
\n
\n \n

The request is made through the adapters' queryRecord:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/user.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Adapter from '@ember-data/adapter';\nimport $ from 'jquery';\n\nexport default class UserAdapter extends Adapter {\n  queryRecord(modelName, query) {\n    return $.getJSON('/api/current_user');\n  }\n}
\n
\n
\n \n

Note: the primary use case for store.queryRecord is when a single record\nis queried and the id is not known beforehand. In all other cases\nstore.query and using the first item of the array is likely the preferred\nway:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
// GET /users?username=unique\n{\n  data: [{\n    id: 1234,\n    type: 'user',\n    attributes: {\n      username: "unique"\n    }\n  }]\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
store.query('user', { username: 'unique' }).then(function(users) {\n  return users.get('firstObject');\n}).then(function(user) {\n  let id = user.get('id');\n});
\n
\n
\n \n

This method returns a promise, which resolves with the found record.

\n

If the adapter returns no data for the primary data of the payload, then\nqueryRecord resolves with null:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n
// GET /users?username=unique\n{\n  data: null\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
store.queryRecord('user', { username: 'unique' }).then(function(user) {\n  console.log(user); // null\n});
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "queryRecord", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "query", + "description": "an opaque query to be used by the adapter", + "type": "Any" + }, + { + "name": "options", + "description": "optional, may include `adapterOptions` hash which will be passed to adapter.queryRecord", + "type": "Object" + } + ], + "return": { + "description": "promise which resolves with the found record or `null`", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2176, + "description": "

findAll asks the adapter's findAll method to find the records for the\ngiven type, and returns a promise which will resolve with all records of\nthis type present in the store, even if the adapter only returns a subset\nof them.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/authors.js
1\n2\n3\n4\n5\n6\n7\n
import Route from '@ember/routing/route';\n\nexport default class AuthorsRoute extends Route {\n  model(params) {\n    return this.store.findAll('author');\n  }\n}
\n
\n
\n \n

When the returned promise resolves depends on the reload behavior,\nconfigured via the passed options hash and the result of the adapter's\nshouldReloadAll method.

\n

Reloading

\n

If { reload: true } is passed or adapter.shouldReloadAll evaluates to\ntrue, then the returned promise resolves once the adapter returns data,\nregardless if there are already records in the store:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
store.push({\n  data: {\n    id: 'first',\n    type: 'author'\n  }\n});\n\n// adapter#findAll resolves with\n// [\n//   {\n//     id: 'second',\n//     type: 'author'\n//   }\n// ]\nstore.findAll('author', { reload: true }).then(function(authors) {\n  authors.getEach('id'); // ['first', 'second']\n});
\n
\n
\n \n

If no reload is indicated via the above mentioned ways, then the promise\nimmediately resolves with all the records currently loaded in the store.

\n

Background Reloading

\n

Optionally, if adapter.shouldBackgroundReloadAll evaluates to true,\nthen a background reload is started. Once this resolves, the array with\nwhich the promise resolves, is updated automatically so it contains all the\nrecords in the store:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n
import Adapter from '@ember-data/adapter';\n\nexport default class ApplicationAdapter extends Adapter {\n  shouldReloadAll(store, snapshotsArray) {\n    return false;\n  },\n\n  shouldBackgroundReloadAll(store, snapshotsArray) {\n    return true;\n  }\n});\n\n// ...\n\nstore.push({\n  data: {\n    id: 'first',\n    type: 'author'\n  }\n});\n\nlet allAuthors;\nstore.findAll('author').then(function(authors) {\n  authors.getEach('id'); // ['first']\n\n  allAuthors = authors;\n});\n\n// later, once adapter#findAll resolved with\n// [\n//   {\n//     id: 'second',\n//     type: 'author'\n//   }\n// ]\n\nallAuthors.getEach('id'); // ['first', 'second']
\n
\n
\n \n

If you would like to force or prevent background reloading, you can set a\nboolean value for backgroundReload in the options object for\nfindAll.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/post/edit.js
1\n2\n3\n4\n5\n6\n7\n
import Route from '@ember/routing/route';\n\nexport default class PostEditRoute extends Route {\n  model() {\n    return this.store.findAll('post', { backgroundReload: false });\n  }\n}
\n
\n
\n \n

If you pass an object on the adapterOptions property of the options\nargument it will be passed to you adapter via the snapshotRecordArray

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/posts.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import Route from '@ember/routing/route';\n\nexport default class PostsRoute extends Route {\n  model(params) {\n    return this.store.findAll('post', {\n      adapterOptions: { subscribe: false }\n    });\n  }\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
import MyCustomAdapter from './custom-adapter';\n\nexport default class UserAdapter extends MyCustomAdapter {\n  findAll(store, type, sinceToken, snapshotRecordArray) {\n    if (snapshotRecordArray.adapterOptions.subscribe) {\n      // ...\n    }\n    // ...\n  }\n}
\n
\n
\n \n

See peekAll to get an array of current records in the\nstore, without waiting until a reload is finished.

\n\n

If you use an adapter such as Ember's default\nJSONAPIAdapter\nthat supports the JSON API specification and if your server\nendpoint supports the use of an\n'include' query parameter,\nyou can use findAll() to automatically retrieve additional records related to\nthose requested by supplying an include parameter in the options object.

\n

For example, given a post model that has a hasMany relationship with a comment\nmodel, when we retrieve all of the post records we can have the server also return\nall of the posts' comments in the same request:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/posts.js
1\n2\n3\n4\n5\n6\n7\n
import Route from '@ember/routing/route';\n\nexport default class PostsRoute extends Route {\n  model() {\n    return this.store.findAll('post', { include: 'comments' });\n  }\n}
\n
\n
\n \n

Multiple relationships can be requested using an include parameter consisting of a\ncomma-separated list (without white-space) while nested relationships can be specified\nusing a dot-separated sequence of relationship names. So to request both the posts'\ncomments and the authors of those comments the request would look like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/posts.js
1\n2\n3\n4\n5\n6\n7\n
import Route from '@ember/routing/route';\n\nexport default class PostsRoute extends Route {\n  model() {\n    return this.store.findAll('post', { include: 'comments,comments.author' });\n  }\n}
\n
\n
\n \n

See query to only get a subset of records from the server.

\n", + "since": "1.13.0", + "itemtype": "method", + "name": "findAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2380, + "itemtype": "method", + "name": "_fetchAll", + "access": "private", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "Model" + }, + { + "name": "array", + "description": "", + "type": "RecordArray" + } + ], + "return": { + "description": "promise", + "type": "Promise" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2429, + "itemtype": "method", + "name": "_didUpdateAll", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "access": "private", + "tagname": "", + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2438, + "description": "

This method returns a filtered array that contains all of the\nknown records for a given type in the store.

\n

Note that because it's just a filter, the result will contain any\nlocally created records of the type, however, it will not make a\nrequest to the backend to retrieve additional records. If you\nwould like to request all the records from the backend please use\nstore.findAll.

\n

Also note that multiple calls to peekAll for a given type will always\nreturn the same RecordArray.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
let localPosts = store.peekAll('post');
\n
\n
\n \n", + "since": "1.13.0", + "itemtype": "method", + "name": "peekAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "", + "type": "RecordArray" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2476, + "description": "

This method unloads all records in the store.\nIt schedules unloading to happen during the next run loop.

\n

Optionally you can pass a type which unload all records for a given type.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.unloadAll();\nstore.unloadAll('post');
\n
\n
\n \n", + "itemtype": "method", + "name": "unloadAll", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2522, + "description": "

This method is called by record.save, and gets passed a\nresolver for the promise that record.save returns.

\n

It schedules saving to happen at the end of the run loop.

\n", + "itemtype": "method", + "name": "scheduleSave", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModel", + "description": "", + "type": "InternalModel" + }, + { + "name": "resolver", + "description": "", + "type": "Resolver" + }, + { + "name": "options", + "description": "", + "type": "Object" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2602, + "description": "

This method is called at the end of the run loop, and\nflushes any records passed into scheduleSave

\n", + "itemtype": "method", + "name": "flushPendingSave", + "access": "private", + "tagname": "", + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2653, + "description": "

This method is called once the promise returned by an\nadapter's createRecord, updateRecord or deleteRecord\nis resolved.

\n

If the data provides a server-generated ID, it will\nupdate the record and the store's indexes.

\n", + "itemtype": "method", + "name": "didSaveRecord", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModel", + "description": "the in-flight internal model", + "type": "InternalModel" + }, + { + "name": "data", + "description": "optional data (see above)", + "type": "Object" + }, + { + "name": "op", + "description": "the adapter operation that was committed", + "type": "String" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2694, + "description": "

This method is called once the promise returned by an\nadapter's createRecord, updateRecord or deleteRecord\nis rejected with a InvalidError.

\n", + "itemtype": "method", + "name": "recordWasInvalid", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModel", + "description": "", + "type": "InternalModel" + }, + { + "name": "errors", + "description": "", + "type": "Object" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2715, + "description": "

This method is called once the promise returned by an\nadapter's createRecord, updateRecord or deleteRecord\nis rejected (with anything other than a InvalidError).

\n", + "itemtype": "method", + "name": "recordWasError", + "access": "private", + "tagname": "", + "params": [ + { + "name": "internalModel", + "description": "", + "type": "InternalModel" + }, + { + "name": "error", + "description": "", + "type": "Error" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2732, + "description": "

Sets newly received ID from the adapter's createRecord, updateRecord\nor deleteRecord.

\n", + "itemtype": "method", + "name": "setRecordId", + "access": "private", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + }, + { + "name": "newId", + "description": "", + "type": "String" + }, + { + "name": "clientId", + "description": "", + "type": "String" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2753, + "description": "

This internal method is used by push.

\n", + "itemtype": "method", + "name": "_load", + "access": "private", + "tagname": "", + "params": [ + { + "name": "data", + "description": "", + "type": "Object" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2796, + "description": "

Push some data for a given type into the store.

\n

This method expects normalized JSON API document. This means you have to follow JSON API specification with few minor adjustments:

\n
    \n
  • record's type should always be in singular, dasherized form
  • \n
  • members (properties) should be camelCased
  • \n
\n

Your primary data should be wrapped inside data property:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
store.push({\n  data: {\n    // primary data for single record of type `Person`\n    id: '1',\n    type: 'person',\n    attributes: {\n      firstName: 'Daniel',\n      lastName: 'Kmak'\n    }\n  }\n});
\n
\n
\n \n

Demo.

\n

data property can also hold an array (of records):

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n
store.push({\n  data: [\n    // an array of records\n    {\n      id: '1',\n      type: 'person',\n      attributes: {\n        firstName: 'Daniel',\n        lastName: 'Kmak'\n      }\n    },\n    {\n      id: '2',\n      type: 'person',\n      attributes: {\n        firstName: 'Tom',\n        lastName: 'Dale'\n      }\n    }\n  ]\n});
\n
\n
\n \n

Demo.

\n

There are some typical properties for JSONAPI payload:

\n
    \n
  • id - mandatory, unique record's key
  • \n
  • type - mandatory string which matches model's dasherized name in singular form
  • \n
  • attributes - object which holds data for record attributes - attr's declared in model
  • \n
  • relationships - object which must contain any of the following properties under each relationships' respective key (example path is relationships.achievements.data):
      \n
    • links
    • \n
    • data - place for primary data
    • \n
    • meta - object which contains meta-information about relationship
    • \n
    \n
  • \n
\n

For this model:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, hasMany } from '@ember-data/model';\n\nexport default class PersonRoute extends Route {\n  @attr('string') firstName;\n  @attr('string') lastName;\n\n  @hasMany('person') children;\n}
\n
\n
\n \n

To represent the children as IDs:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n
{\n  data: {\n    id: '1',\n    type: 'person',\n    attributes: {\n      firstName: 'Tom',\n      lastName: 'Dale'\n    },\n    relationships: {\n      children: {\n        data: [\n          {\n            id: '2',\n            type: 'person'\n          },\n          {\n            id: '3',\n            type: 'person'\n          },\n          {\n            id: '4',\n            type: 'person'\n          }\n        ]\n      }\n    }\n  }\n}
\n
\n
\n \n

Demo.

\n

To represent the children relationship as a URL:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
{\n  data: {\n    id: '1',\n    type: 'person',\n    attributes: {\n      firstName: 'Tom',\n      lastName: 'Dale'\n    },\n    relationships: {\n      children: {\n        links: {\n          related: '/people/1/children'\n        }\n      }\n    }\n  }\n}
\n
\n
\n \n

If you're streaming data or implementing an adapter, make sure\nthat you have converted the incoming data into this form. The\nstore's normalize method is a convenience\nhelper for converting a json payload into the form Ember Data\nexpects.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
store.push(store.normalize('person', data));
\n
\n
\n \n

This method can be used both to push in brand new\nrecords, as well as to update existing records.

\n", + "itemtype": "method", + "name": "push", + "access": "public", + "tagname": "", + "params": [ + { + "name": "data", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "the record(s) that was created or\n updated." + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 2969, + "description": "

Push some data in the form of a json-api document into the store,\nwithout creating materialized records.

\n", + "itemtype": "method", + "name": "_push", + "access": "private", + "tagname": "", + "params": [ + { + "name": "jsonApiDoc", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "pushed InternalModel(s)", + "type": "InternalModel|Array" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 3081, + "description": "

Push some raw data into the store.

\n

This method can be used both to push in brand new\nrecords, as well as to update existing records. You\ncan push in more than one type of object at once.\nAll objects should be in the format expected by the\nserializer.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n
import RESTSerializer from '@ember-data/serializer/rest';\n\nexport default class ApplicationSerializer extends RESTSerializer;
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
let pushData = {\n  posts: [\n    { id: 1, postTitle: "Great post", commentIds: [2] }\n  ],\n  comments: [\n    { id: 2, commentBody: "Insightful comment" }\n  ]\n}\n\nstore.pushPayload(pushData);
\n
\n
\n \n

By default, the data will be deserialized using a default\nserializer (the application serializer if it exists).

\n

Alternatively, pushPayload will accept a model type which\nwill determine which serializer will process the payload.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n
import RESTSerializer from '@ember-data/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer;
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/post.js
1\n2\n3\n
import JSONSerializer from '@ember-data/serializer/json';\n\nexport default JSONSerializer;
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.pushPayload(pushData); // Will use the application serializer\nstore.pushPayload('post', pushData); // Will use the post serializer
\n
\n
\n \n", + "itemtype": "method", + "name": "pushPayload", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "Optionally, a model type used to determine which serializer will be used", + "type": "String" + }, + { + "name": "inputPayload", + "description": "", + "type": "Object" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 3240, + "description": "

Instantiation hook allowing applications or addons to configure the store\nto utilize a custom RecordData implementation.

\n", + "itemtype": "method", + "name": "createRecordDataFor", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "" + }, + { + "name": "id", + "description": "" + }, + { + "name": "clientId", + "description": "" + }, + { + "name": "storeWrapper", + "description": "" + } + ], + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 3302, + "description": "

normalize converts a json payload into the normalized form that\npush expects.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
socket.on('message', function(message) {\n  let modelName = message.model;\n  let data = message.data;\n  store.push(store.normalize(modelName, data));\n});
\n
\n
\n \n", + "itemtype": "method", + "name": "normalize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "The name of the model type for this payload", + "type": "String" + }, + { + "name": "payload", + "description": "", + "type": "Object" + } + ], + "return": { + "description": "The normalized payload", + "type": "Object" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 3364, + "description": "

Returns an instance of the adapter for a given type. For\nexample, adapterFor('person') will return an instance of\nApp.PersonAdapter.

\n

If no App.PersonAdapter is found, this method will look\nfor an App.ApplicationAdapter (the default adapter for\nyour entire application).

\n

If no App.ApplicationAdapter is found, it will return\nthe value of the defaultAdapter.

\n", + "itemtype": "method", + "name": "adapterFor", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "Adapter" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 3466, + "description": "

Returns an instance of the serializer for a given type. For\nexample, serializerFor('person') will return an instance of\nApp.PersonSerializer.

\n

If no App.PersonSerializer is found, this method will look\nfor an App.ApplicationSerializer (the default serializer for\nyour entire application).

\n

if no App.ApplicationSerializer is found, it will attempt\nto get the defaultSerializer from the PersonAdapter\n(adapterFor('person')).

\n

If a serializer cannot be found on the adapter, it will fall back\nto an instance of JSONSerializer.

\n", + "itemtype": "method", + "name": "serializerFor", + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "the record to serialize", + "type": "String" + } + ], + "return": { + "description": "", + "type": "Serializer" + }, + "class": "Store", + "module": "@ember-data/store" + } + ], + "events": [], + "properties": [ + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 227, + "description": "

EmberData specific backburner instance

\n", + "itemtype": "property", + "name": "_backburner", + "access": "private", + "tagname": "", + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 267, + "description": "

The default adapter to use to communicate to a backend server or\nother persistence layer. This will be overridden by an application\nadapter if present.

\n

If you want to specify app/adapters/custom.js as a string, do:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
import Store from '@ember-data/store';\n\nexport default Store.extend({\n  constructor() {\n    super(...arguments);\n    this.adapter = 'custom';\n  }\n}
\n
\n
\n \n", + "itemtype": "property", + "name": "adapter", + "access": "public", + "tagname": "", + "default": "'-json-api'", + "type": "{String}", + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 291, + "description": "

This property returns the adapter, after resolving a possible\nstring key.

\n

If the supplied adapter was a class, or a String property\npath resolved to a class, this property will instantiate the\nclass.

\n

This property is cacheable, so the same instance of a specified\nadapter class should be used for the lifetime of the store.

\n", + "itemtype": "property", + "name": "defaultAdapter", + "access": "private", + "tagname": "", + "return": { + "description": "Adapter" + }, + "class": "Store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/core-store.ts", + "line": 429, + "description": "

Provides access to the IdentifierCache instance\nfor this store.

\n

The IdentifierCache can be used to generate or\nretrieve a stable unique identifier for any resource.

\n", + "itemtype": "property", + "name": "identifierCache", + "type": "IdentifierCache", + "access": "public", + "tagname": "", + "class": "Store", + "module": "@ember-data/store" + } + ] + }, + "relationships": { + "parent-class": { + "data": { + "id": "Ember.Service", + "type": "missing" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-StringTransform-e22b28a886.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-StringTransform-e22b28a886.json new file mode 100644 index 000000000..981fa897b --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-StringTransform-e22b28a886.json @@ -0,0 +1,102 @@ +{ + "data": { + "id": "ember-data-3.28.13-StringTransform", + "type": "class", + "attributes": { + "name": "StringTransform", + "shortname": "StringTransform", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer", + "namespace": "", + "file": "../serializer/addon/-private/transforms/string.js", + "line": 9, + "description": "

The StringTransform class is used to serialize and deserialize\nstring attributes on Ember Data record objects. This transform is\nused when string is passed as the type parameter to the\nattr function.

\n

Usage

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @attr('boolean') isAdmin;\n  @attr('string') name;\n  @attr('string') email;\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "Transform", + "methods": [ + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 80, + "description": "

When given a deserialized value from a record attribute this\nmethod must return the serialized value.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
import { isEmpty } from '@ember/utils';\n\nserialize(deserialized, options) {\n  return isEmpty(deserialized) ? null : Number(deserialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "deserialized", + "description": "The deserialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The serialized value" + }, + "class": "StringTransform", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Transform" + }, + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 102, + "description": "

When given a serialized value from a JSON object this method must\nreturn the deserialized value for the record attribute.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
deserialize(serialized, options) {\n  return empty(serialized) ? null : Number(serialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deserialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "serialized", + "description": "The serialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The deserialized value" + }, + "class": "StringTransform", + "module": "@ember-data/serializer", + "inherited": true, + "inheritedFrom": "Transform" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-Transform", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-TimeoutError-1cef024b23.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-TimeoutError-1cef024b23.json new file mode 100644 index 000000000..9eb799610 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-TimeoutError-1cef024b23.json @@ -0,0 +1,49 @@ +{ + "data": { + "id": "ember-data-3.28.13-TimeoutError", + "type": "class", + "attributes": { + "name": "TimeoutError", + "shortname": "TimeoutError", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter/error", + "namespace": "", + "file": "../adapter/addon/error.js", + "line": 185, + "description": "

A TimeoutError is used by an adapter to signal that a request\nto the external API has timed out. I.e. no response was received from\nthe external API within an allowed time period.

\n

An example use case would be to warn the user to check their internet\nconnection if an adapter operation has timed out:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n
import Route from '@ember/routing/route';\nimport { TimeoutError } from '@ember-data/adapter/error';\nimport { action } from '@ember/object';\n\nexport default class ApplicationRoute extends Route {\n  @action\n  error(error, transition) {\n    if (error instanceof TimeoutError) {\n      // alert the user\n      alert('Are you still connected to the Internet?');\n      return;\n    }\n\n    // ...other error handling logic\n  }\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "AdapterError", + "methods": [], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-AdapterError", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/error", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Transform-5f90a14566.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Transform-5f90a14566.json new file mode 100644 index 000000000..fb491c520 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-Transform-5f90a14566.json @@ -0,0 +1,111 @@ +{ + "data": { + "id": "ember-data-3.28.13-Transform", + "type": "class", + "attributes": { + "name": "Transform", + "shortname": "Transform", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/serializer", + "namespace": "", + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 7, + "description": "

The Transform class is used to serialize and deserialize model\nattributes when they are saved or loaded from an\nadapter. Subclassing Transform is useful for creating custom\nattributes. All subclasses of Transform must implement a\nserialize and a deserialize method.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/transforms/temperature.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import Transform from '@ember-data/serializer/transform';\n\n// Converts centigrade in the JSON to fahrenheit in the app\nexport default class TemperatureTransform extends Transform {\n  deserialize(serialized, options) {\n    return (serialized *  1.8) + 32;\n  }\n\n  serialize(deserialized, options) {\n    return (deserialized - 32) / 1.8;\n  }\n}
\n
\n
\n \n

Usage

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/requirement.js
1\n2\n3\n4\n5\n6\n
import Model, { attr } from '@ember-data/model';\n\nexport default class RequirementModel extends Model {\n  @attr('string') name;\n  @attr('temperature') temperature;\n}
\n
\n
\n \n

The options passed into the attr function when the attribute is\ndeclared on the model is also available in the transform.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/post.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import Model, { attr } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n  @attr('string') title;\n  @attr('markdown', {\n    markdown: {\n      gfm: false,\n      sanitize: true\n    }\n  })\n  markdown;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/transforms/markdown.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n
import Transform from '@ember-data/serializer/transform';\n\nexport default class MarkdownTransform extends Transform {\n  serialize(deserialized, options) {\n    return deserialized.raw;\n  }\n\n  deserialize(serialized, options) {\n    let markdownOptions = options.markdown || {};\n\n    return marked(serialized, markdownOptions);\n  }\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "methods": [ + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 80, + "description": "

When given a deserialized value from a record attribute this\nmethod must return the serialized value.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
import { isEmpty } from '@ember/utils';\n\nserialize(deserialized, options) {\n  return isEmpty(deserialized) ? null : Number(deserialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "serialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "deserialized", + "description": "The deserialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The serialized value" + }, + "class": "Transform", + "module": "@ember-data/serializer" + }, + { + "file": "../serializer/addon/-private/transforms/transform.js", + "line": 102, + "description": "

When given a serialized value from a JSON object this method must\nreturn the deserialized value for the record attribute.

\n

Example

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
deserialize(serialized, options) {\n  return empty(serialized) ? null : Number(serialized);\n}
\n
\n
\n \n", + "itemtype": "method", + "name": "deserialize", + "access": "public", + "tagname": "", + "params": [ + { + "name": "serialized", + "description": "The serialized value" + }, + { + "name": "options", + "description": "hash of options passed to `attr`" + } + ], + "return": { + "description": "The deserialized value" + }, + "class": "Transform", + "module": "@ember-data/serializer" + } + ], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": null + }, + "descendants": { + "data": [ + { + "type": "class", + "id": "ember-data-3.28.13-BooleanTransform" + }, + { + "type": "class", + "id": "ember-data-3.28.13-DateTransform" + }, + { + "type": "class", + "id": "ember-data-3.28.13-NumberTransform" + }, + { + "type": "class", + "id": "ember-data-3.28.13-StringTransform" + } + ] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-UnauthorizedError-83658f3060.json b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-UnauthorizedError-83658f3060.json new file mode 100644 index 000000000..722a22fc7 --- /dev/null +++ b/json-docs/ember-data/3.28.13/classes/ember-data-3.28.13-UnauthorizedError-83658f3060.json @@ -0,0 +1,49 @@ +{ + "data": { + "id": "ember-data-3.28.13-UnauthorizedError", + "type": "class", + "attributes": { + "name": "UnauthorizedError", + "shortname": "UnauthorizedError", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "module": "@ember-data/adapter/error", + "namespace": "", + "file": "../adapter/addon/error.js", + "line": 232, + "description": "

A UnauthorizedError equates to a HTTP 401 Unauthorized response\nstatus. It is used by an adapter to signal that a request to the external\nAPI was rejected because authorization is required and has failed or has not\nyet been provided.

\n

An example use case would be to redirect the user to a login route if a\nrequest is unauthorized:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n
import Route from '@ember/routing/route';\nimport { UnauthorizedError } from '@ember-data/adapter/error';\nimport { action } from '@ember/object';\n\nexport default class ApplicationRoute extends Route {\n  @action\n  error(error, transition) {\n    if (error instanceof UnauthorizedError) {\n      // go to the login route\n      this.transitionTo('login');\n      return;\n    }\n\n    // ...other error handling logic\n  }\n}
\n
\n
\n \n", + "access": "public", + "tagname": "", + "extends": "AdapterError", + "methods": [], + "events": [], + "properties": [] + }, + "relationships": { + "parent-class": { + "data": { + "id": "ember-data-3.28.13-AdapterError", + "type": "class" + } + }, + "descendants": { + "data": [] + }, + "module": { + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/error", + "type": "module" + } + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter-44a8d9698e.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter-44a8d9698e.json new file mode 100644 index 000000000..c4ebb9c0d --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter-44a8d9698e.json @@ -0,0 +1,39 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter", + "type": "module", + "attributes": { + "name": "@ember-data/adapter", + "submodules": {}, + "elements": {}, + "fors": {}, + "namespaces": {}, + "tag": "main", + "file": "../store/addon/-private/ts-interfaces/minimum-adapter-interface.ts", + "line": 19, + "description": "

Overview

\n

In order to properly fetch and update data, EmberData\nneeds to understand how to connect to your API.

\n

Adapters accept various kinds of requests from the store\nand manage fulfillment of the request from your API.

\n

Request Flow

\n

When the store decides it needs to issue a request it uses the\nfollowing flow to manage the request and process the data.

\n
    \n
  • find the appropriate adapter
  • \n
  • issue the request to the adapter
  • \n
  • await the adapter's response
      \n
    • if an error occurs reject with the error
    • \n
    • if no error
        \n
      • if there is response data
          \n
        • pass the response data to the appropriate serializer
        • \n
        • update the cache using the JSON:API formatted data from the serializer's response
        • \n
        \n
      • \n
      • return the primary record(s) associated with the request
      • \n
      \n
    • \n
    \n
  • \n
\n

Request Errors

\n

When a request errors and your adapter does not have the ability to recover from the error,\nyou may either reject the promise returned by your adapter method with the error or simply\nthrow the error.

\n

If the request was for a createRecord updateRecord or deleteRecord special rules\napply to how this error will affect the state of the store and additional properties on\nthe Error class may be used. See the documentation for these methods in the\nMinimumAdapterInterface for more information.

\n

Implementing an Adapter

\n

There are seven required adapter methods, one for each of\nthe primary request types that EmberData issues.

\n

They are:

\n
    \n
  • findRecord
  • \n
  • findAll
  • \n
  • queryRecord
  • \n
  • query
  • \n
  • createRecord
  • \n
  • updateRecord
  • \n
  • deleteRecord
  • \n
\n

Each of these request types has a matching store method that triggers it\nand matching requestType that is passed to the serializer's\nnormalizeResponse method.

\n

If your app only reads data but never writes data, it is not necessary\nto implement the methods for create, update, and delete. This extends to\nall of the store's find methods with the exception of findRecord (findAll,\nquery, queryRecord): if you do not use the store method in your app then\nyour Adapter does not need the method.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import EmberObject from '@ember/object';\n\nasync function fetchData(url, options = {}) {\n  let response = await fetch(url, options);\n  return response.toJSON();\n}\n\nexport default class ApplicationAdapter extends EmberObject {\n  findRecord(_, { modelName }, id) {\n    return fetchData(`./${modelName}s/${id}`);\n  }\n}
\n
\n
\n \n

Adapter Resolution

\n

store.adapterFor(name) will lookup adapters defined in app/adapters/ and\nreturn an instance.

\n

adapterFor first attempts to find an adapter with an exact match on name,\nthen falls back to checking for the presence of an adapter named application.

\n

If no adapter is found, an error will be thrown.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
store.adapterFor('author');\n\n// lookup paths (in order) =>\n//   app/adapters/author.js\n//   app/adapters/application.js
\n
\n
\n \n

Most requests in EmberData are made with respect to a particular type (or modelName)\n(e.g., "get me the full collection of books" or "get me the employee whose id is 37"). We\nrefer to this as the primary resource type.

\n

adapterFor is used by the store to find an adapter with a name matching that of the primary\nresource type for the request, which then falls back to the application adapter.

\n

It is recommended that applications define only a single application adapter and serializer\nwhere possible, only implementing an adapter specific to the type when absolutely necessary.

\n

If you need to support multiple API versions for the same type, the per-type strategy for\ndefining adapters might not be adequate.

\n

If you have multiple APIs or multiple API versions and the single application adapter and per-type\nstrategy does not suite your needs, one strategy is to write an application adapter and serializer\nthat make use of options to specify the desired format when making a request, then forwards to the\nrequest to the desired adapter or serializer as needed.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n
export default class Adapter extends EmberObject {\n  findRecord(store, schema, id, snapshot) {\n    let { apiVersion } = snapshot.adapterOptions;\n    return this.adapterFor(`-api-${apiVersion}`).findRecord(store, schema, id, snapshot);\n  }\n}
\n
\n
\n \n

Using an Adapter

\n

Any adapter in app/adapters/ can be looked up by name using store.adapterFor(name).

\n

Default Adapters

\n

Applications whose API's structure endpoint URLs very close to or exactly the REST\nor JSON:API convention, the @ember-data/adapter package contains implementations\nthese applications can extend.

\n

Many applications will find writing their own adapter to be allow greater flexibility,\ncustomization, and maintenance than attempting to override methods in these adapters.

\n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "BuildURLMixin", + "Adapter", + "MinimumAdapterInterface" + ], + "privateclasses": [], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/error-80a5cf85b4.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/error-80a5cf85b4.json new file mode 100644 index 000000000..5fcb69852 --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/error-80a5cf85b4.json @@ -0,0 +1,145 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/error", + "type": "module", + "attributes": { + "name": "@ember-data/adapter/error", + "submodules": {}, + "elements": {}, + "fors": { + "@ember-data/adapter/error": 1 + }, + "namespaces": {}, + "tag": "main", + "file": "../adapter/addon/error.js", + "line": 334, + "description": "

A AdapterError is used by an adapter to signal that an error occurred\nduring a request to an external API. It indicates a generic error, and\nsubclasses are used to indicate specific error states. The following\nsubclasses are provided:

\n
    \n
  • InvalidError
  • \n
  • TimeoutError
  • \n
  • AbortError
  • \n
  • UnauthorizedError
  • \n
  • ForbiddenError
  • \n
  • NotFoundError
  • \n
  • ConflictError
  • \n
  • ServerError
  • \n
\n

To create a custom error to signal a specific error state in communicating\nwith an external API, extend the AdapterError. For example, if the\nexternal API exclusively used HTTP 503 Service Unavailable to indicate\nit was closed for maintenance:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
error.js
1\n2\n3\n
import AdapterError from '@ember-data/adapter/error';\n\nexport default AdapterError.extend({ message: "Down for maintenance." });
\n
\n
\n \n

This error would then be returned by an adapter's handleResponse method:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\nimport MaintenanceError from './maintenance-error';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  handleResponse(status) {\n    if (503 === status) {\n      return new MaintenanceError();\n    }\n\n    return this._super(...arguments);\n  }\n}
\n
\n
\n \n

And can then be detected in an application and used to send the user to an\nunder-maintenance route:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/routes/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n
import Route from '@ember/routing/route';\nimport MaintenanceError from '../adapters/maintenance-error';\n\nexport default class ApplicationRoute extends Route {\n  actions: {\n    error(error, transition) {\n      if (error instanceof MaintenanceError) {\n        this.transitionTo('under-maintenance');\n        return;\n      }\n\n      // ...other error handling logic\n    }\n  }\n}
\n
\n
\n \n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "AdapterError", + "InvalidError", + "TimeoutError", + "AbortError", + "UnauthorizedError", + "ForbiddenError", + "NotFoundError", + "ConflictError", + "ServerError" + ], + "privateclasses": [], + "staticfunctions": { + "@ember-data/adapter/error": [ + { + "file": "../store/addon/-private/system/errors-utils.js", + "line": 82, + "description": "Convert an array of errors in JSON-API format into an object.\n\n```javascript\nimport DS from 'ember-data';\n\nconst { errorsArrayToHash } = DS;\n\nlet errorsArray = [\n {\n title: 'Invalid Attribute',\n detail: 'Must be present',\n source: { pointer: '/data/attributes/name' }\n },\n {\n title: 'Invalid Attribute',\n detail: 'Must be present',\n source: { pointer: '/data/attributes/age' }\n },\n {\n title: 'Invalid Attribute',\n detail: 'Must be a number',\n source: { pointer: '/data/attributes/age' }\n }\n];\n\nlet errors = errorsArrayToHash(errorsArray);\n// {\n// \"name\": [\"Must be present\"],\n// \"age\": [\"Must be present\", \"must be a number\"]\n// }\n```", + "itemtype": "method", + "name": "errorsArrayToHash", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "errors", + "description": "array of errors in JSON-API format", + "type": "Array" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "@ember-data/adapter/error", + "module": "@ember-data/adapter/error" + }, + { + "file": "../store/addon/-private/system/errors-utils.js", + "line": 12, + "description": "Convert an hash of errors into an array with errors in JSON-API format.\n ```javascript\nimport DS from 'ember-data';\n\n const { errorsHashToArray } = DS;\n \n let errors = {\n base: 'Invalid attributes on saving this record',\n name: 'Must be present',\n age: ['Must be present', 'Must be a number']\n};\n let errorsArray = errorsHashToArray(errors);\n// [\n// {\n// title: \"Invalid Document\",\n// detail: \"Invalid attributes on saving this record\",\n// source: { pointer: \"/data\" }\n// },\n// {\n// title: \"Invalid Attribute\",\n// detail: \"Must be present\",\n// source: { pointer: \"/data/attributes/name\" }\n// },\n// {\n// title: \"Invalid Attribute\",\n// detail: \"Must be present\",\n// source: { pointer: \"/data/attributes/age\" }\n// },\n// {\n// title: \"Invalid Attribute\",\n// detail: \"Must be a number\",\n// source: { pointer: \"/data/attributes/age\" }\n// }\n// ]\n```", + "itemtype": "method", + "name": "errorsHashToArray", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "errors", + "description": "hash with errors as properties", + "type": "Object" + } + ], + "return": { + "description": "array of errors in JSON-API format", + "type": "Array" + }, + "class": "@ember-data/adapter/error", + "module": "@ember-data/adapter/error" + } + ] + }, + "allstaticfunctions": { + "@ember-data/adapter/error": [ + { + "file": "../store/addon/-private/system/errors-utils.js", + "line": 82, + "description": "Convert an array of errors in JSON-API format into an object.\n\n```javascript\nimport DS from 'ember-data';\n\nconst { errorsArrayToHash } = DS;\n\nlet errorsArray = [\n {\n title: 'Invalid Attribute',\n detail: 'Must be present',\n source: { pointer: '/data/attributes/name' }\n },\n {\n title: 'Invalid Attribute',\n detail: 'Must be present',\n source: { pointer: '/data/attributes/age' }\n },\n {\n title: 'Invalid Attribute',\n detail: 'Must be a number',\n source: { pointer: '/data/attributes/age' }\n }\n];\n\nlet errors = errorsArrayToHash(errorsArray);\n// {\n// \"name\": [\"Must be present\"],\n// \"age\": [\"Must be present\", \"must be a number\"]\n// }\n```", + "itemtype": "method", + "name": "errorsArrayToHash", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "errors", + "description": "array of errors in JSON-API format", + "type": "Array" + } + ], + "return": { + "description": "", + "type": "Object" + }, + "class": "@ember-data/adapter/error", + "module": "@ember-data/adapter/error" + }, + { + "file": "../store/addon/-private/system/errors-utils.js", + "line": 12, + "description": "Convert an hash of errors into an array with errors in JSON-API format.\n ```javascript\nimport DS from 'ember-data';\n\n const { errorsHashToArray } = DS;\n \n let errors = {\n base: 'Invalid attributes on saving this record',\n name: 'Must be present',\n age: ['Must be present', 'Must be a number']\n};\n let errorsArray = errorsHashToArray(errors);\n// [\n// {\n// title: \"Invalid Document\",\n// detail: \"Invalid attributes on saving this record\",\n// source: { pointer: \"/data\" }\n// },\n// {\n// title: \"Invalid Attribute\",\n// detail: \"Must be present\",\n// source: { pointer: \"/data/attributes/name\" }\n// },\n// {\n// title: \"Invalid Attribute\",\n// detail: \"Must be present\",\n// source: { pointer: \"/data/attributes/age\" }\n// },\n// {\n// title: \"Invalid Attribute\",\n// detail: \"Must be a number\",\n// source: { pointer: \"/data/attributes/age\" }\n// }\n// ]\n```", + "itemtype": "method", + "name": "errorsHashToArray", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "errors", + "description": "hash with errors as properties", + "type": "Object" + } + ], + "return": { + "description": "array of errors in JSON-API format", + "type": "Array" + }, + "class": "@ember-data/adapter/error", + "module": "@ember-data/adapter/error" + } + ] + }, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/json-api-8cc1851d56.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/json-api-8cc1851d56.json new file mode 100644 index 000000000..95d109c7e --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/json-api-8cc1851d56.json @@ -0,0 +1,38 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/json-api", + "type": "module", + "attributes": { + "name": "@ember-data/adapter/json-api", + "submodules": {}, + "elements": {}, + "fors": {}, + "namespaces": {}, + "tag": "main", + "file": "../adapter/addon/json-api.ts", + "line": 18, + "description": "

The JSONAPIAdapter is the default adapter used by Ember Data. It\nis responsible for transforming the store's requests into HTTP\nrequests that follow the JSON API\nformat.

\n

JSON API Conventions

\n

The JSONAPIAdapter uses JSON API conventions for building the URL\nfor a record and selecting the HTTP verb to use with a request. The\nactions you can take on a record map onto the following URLs in the\nJSON API adapter:

\n\n\n \n \n \n\n\n \n \n \n\n\n \n \n \n\n\n \n \n \n\n\n \n \n \n\n\n \n \n \n\n
\n Action\n \n HTTP Verb\n \n URL\n
\n `store.findRecord('post', 123)`\n \n GET\n \n /posts/123\n
\n `store.findAll('post')`\n \n GET\n \n /posts\n
\n Update `postRecord.save()`\n \n PATCH\n \n /posts/123\n
\n Create `store.createRecord('post').save()`\n \n POST\n \n /posts\n
\n Delete `postRecord.destroyRecord()`\n \n DELETE\n \n /posts/123\n
\n\n

Success and failure

\n

The JSONAPIAdapter will consider a success any response with a\nstatus code of the 2xx family ("Success"), as well as 304 ("Not\nModified"). Any other status code will be considered a failure.

\n

On success, the request promise will be resolved with the full\nresponse payload.

\n

Failed responses with status code 422 ("Unprocessable Entity") will\nbe considered "invalid". The response will be discarded, except for\nthe errors key. The request promise will be rejected with a\nInvalidError. This error object will encapsulate the saved\nerrors value.

\n

Any other status codes will be treated as an adapter error. The\nrequest promise will be rejected, similarly to the invalid case,\nbut with an instance of AdapterError instead.

\n

Endpoint path customization

\n

Endpoint paths can be prefixed with a namespace by setting the\nnamespace property on the adapter:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  namespace = 'api/1';\n}
\n
\n
\n \n

Requests for the person model would now target /api/1/people/1.

\n

Host customization

\n

An adapter can target other hosts by setting the host property.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default class ApplicationAdapter extends JSONAPIAdapter {\n  host = 'https://api.example.com';\n}
\n
\n
\n \n

Requests for the person model would now target\nhttps://api.example.com/people/1.

\n", + "since": "1.13.0", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "JSONAPIAdapter" + ], + "privateclasses": [], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/rest-1271a8f380.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/rest-1271a8f380.json new file mode 100644 index 000000000..a44b7dbcf --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/adapter/rest-1271a8f380.json @@ -0,0 +1,39 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/adapter/rest", + "type": "module", + "attributes": { + "name": "@ember-data/adapter/rest", + "submodules": {}, + "elements": {}, + "fors": { + "@ember-data/adapter/rest": 1 + }, + "namespaces": {}, + "tag": "main", + "file": "../adapter/addon/rest.ts", + "line": 79, + "description": "

The REST adapter allows your store to communicate with an HTTP server by\ntransmitting JSON via XHR. Most Ember.js apps that consume a JSON API\nshould use the REST adapter.

\n

This adapter is designed around the idea that the JSON exchanged with\nthe server should be conventional.

\n

Success and failure

\n

The REST adapter will consider a success any response with a status code\nof the 2xx family ("Success"), as well as 304 ("Not Modified"). Any other\nstatus code will be considered a failure.

\n

On success, the request promise will be resolved with the full response\npayload.

\n

Failed responses with status code 422 ("Unprocessable Entity") will be\nconsidered "invalid". The response will be discarded, except for the\nerrors key. The request promise will be rejected with a InvalidError.\nThis error object will encapsulate the saved errors value.

\n

Any other status codes will be treated as an "adapter error". The request\npromise will be rejected, similarly to the "invalid" case, but with\nan instance of AdapterError instead.

\n

JSON Structure

\n

The REST adapter expects the JSON returned from your server to follow\nthese conventions.

\n

Object Root

\n

The JSON payload should be an object that contains the record inside a\nroot property. For example, in response to a GET request for\n/posts/1, the JSON should look like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n
{\n  "posts": {\n    "id": 1,\n    "title": "I'm Running to Reform the W3C's Tag",\n    "author": "Yehuda Katz"\n  }\n}
\n
\n
\n \n

Similarly, in response to a GET request for /posts, the JSON should\nlook like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n
{\n  "posts": [\n    {\n      "id": 1,\n      "title": "I'm Running to Reform the W3C's Tag",\n      "author": "Yehuda Katz"\n    },\n    {\n      "id": 2,\n      "title": "Rails is omakase",\n      "author": "D2H"\n    }\n  ]\n}
\n
\n
\n \n

Note that the object root can be pluralized for both a single-object response\nand an array response: the REST adapter is not strict on this. Further, if the\nHTTP server responds to a GET request to /posts/1 (e.g. the response to a\nfindRecord query) with more than one object in the array, Ember Data will\nonly display the object with the matching ID.

\n

Conventional Names

\n

Attribute names in your JSON payload should be the camelCased versions of\nthe attributes in your Ember.js models.

\n

For example, if you have a Person model:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr } from '@ember-data/model';\n\nexport default Model.extend({\n  firstName: attr('string'),\n  lastName: attr('string'),\n  occupation: attr('string')\n});
\n
\n
\n \n

The JSON returned should look like this:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
{\n  "people": {\n    "id": 5,\n    "firstName": "Zaphod",\n    "lastName": "Beeblebrox",\n    "occupation": "President"\n  }\n}
\n
\n
\n \n

Relationships

\n

Relationships are usually represented by ids to the record in the\nrelationship. The related records can then be sideloaded in the\nresponse under a key for the type.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
{\n  "posts": {\n    "id": 5,\n    "title": "I'm Running to Reform the W3C's Tag",\n    "author": "Yehuda Katz",\n    "comments": [1, 2]\n  },\n  "comments": [{\n    "id": 1,\n    "author": "User 1",\n    "message": "First!",\n  }, {\n    "id": 2,\n    "author": "User 2",\n    "message": "Good Luck!",\n  }]\n}
\n
\n
\n \n

If the records in the relationship are not known when the response\nis serialized it's also possible to represent the relationship as a\nURL using the links key in the response. Ember Data will fetch\nthis URL to resolve the relationship when it is accessed for the\nfirst time.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n
{\n  "posts": {\n    "id": 5,\n    "title": "I'm Running to Reform the W3C's Tag",\n    "author": "Yehuda Katz",\n    "links": {\n      "comments": "/posts/5/comments"\n    }\n  }\n}
\n
\n
\n \n

Errors

\n

If a response is considered a failure, the JSON payload is expected to include\na top-level key errors, detailing any specific issues. For example:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
{\n  "errors": {\n    "msg": "Something went wrong"\n  }\n}
\n
\n
\n \n

This adapter does not make any assumptions as to the format of the errors\nobject. It will simply be passed along as is, wrapped in an instance\nof InvalidError or AdapterError. The serializer can interpret it\nafterwards.

\n

Customization

\n

Endpoint path customization

\n

Endpoint paths can be prefixed with a namespace by setting the namespace\nproperty on the adapter:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  namespace = 'api/1';\n}
\n
\n
\n \n

Requests for the Person model would now target /api/1/people/1.

\n

Host customization

\n

An adapter can target other hosts by setting the host property.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n
import RESTAdapter from '@ember-data/adapter/rest';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  host = 'https://api.example.com';\n}
\n
\n
\n \n

Headers customization

\n

Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary\nheaders can be set as key/value pairs on the RESTAdapter's headers\nobject and Ember Data will send them along with each ajax request.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { computed } from '@ember/object';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  headers: computed(function() {\n    return {\n      'API_KEY': 'secret key',\n      'ANOTHER_HEADER': 'Some header value'\n    };\n  }\n}
\n
\n
\n \n

headers can also be used as a computed property to support dynamic\nheaders. In the example below, the session object has been\ninjected into an adapter by Ember's container.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { computed } from '@ember/object';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  headers: computed('session.authToken', function() {\n    return {\n      'API_KEY': this.get('session.authToken'),\n      'ANOTHER_HEADER': 'Some header value'\n    };\n  })\n}
\n
\n
\n \n

In some cases, your dynamic headers may require data from some\nobject outside of Ember's observer system (for example\ndocument.cookie). You can use the\nvolatile\nfunction to set the property into a non-cached mode causing the headers to\nbe recomputed with every request.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n
import RESTAdapter from '@ember-data/adapter/rest';\nimport { get } from '@ember/object';\nimport { computed } from '@ember/object';\n\nexport default class ApplicationAdapter extends RESTAdapter {\n  headers: computed(function() {\n    return {\n      'API_KEY': get(document.cookie.match(/apiKey\\=([^;]*)/), '1'),\n      'ANOTHER_HEADER': 'Some header value'\n    };\n  }).volatile()\n}
\n
\n
\n \n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "RESTAdapter" + ], + "privateclasses": [], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/canary-features-26e7210afe.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/canary-features-26e7210afe.json new file mode 100644 index 000000000..32ab31c70 --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/canary-features-26e7210afe.json @@ -0,0 +1,35 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/canary-features", + "type": "module", + "attributes": { + "name": "@ember-data/canary-features", + "submodules": {}, + "elements": {}, + "fors": {}, + "namespaces": {}, + "tag": "main", + "file": "../canary-features/addon/default-features.ts", + "line": 1, + "description": "

Canary Features

\n

EmberData allows users to test features that are implemented but not yet\navailable even in canary.

\n

Typically these features represent work that might introduce a new concept,\nnew API, change an API, or risk an unintended change in behavior to consuming\napplications.

\n

Such features have their implementations guarded by a "feature flag", and the\nflag is only activated once the core-data team is prepared to ship the work\nin a canary release.

\n

Installing Canary

\n

To test a feature you MUST be using a canary build. Canary builds are published\nto npm and can be installed using a precise tag (such as ember-data@3.16.0-alpha.1)\nor by installing the latest dist-tag published to the canary channel.

\n

Using npm to install the latest canary

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
npm install --save-dev ember-data@canary
\n
\n
\n \n

Using yarn to install the latest canary

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
yarn add ember-data@canary
\n
\n
\n \n

Activating a Canary Feature

\n

Once you have installed canary, feature-flags can be activated at build-time by an environment\nvariable or at runtime using window.EmberDataENV.

\n

The "off" branch of feature-flagged code is always stripped from production builds, so you\nMUST use the build-time environment variable to activate a flag if testing production.

\n

The list of available feature-flags is located here

\n

Runtime Configuration

\n

To configure feature-flags at runtime you will want to configure window.EmberDataENV = {} appropriately.\nYou should add this global property in your app prior to your application booting. At the top of\nyour app.js file is a convenient location, as is within index.html as a script running prior\nto loading any other scripts.

\n

Example activating a single feature flags

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
window.EmberDataENV = {\n  FEATURES: {\n    RECORD_DATA_ERRORS: true,\n  }\n}
\n
\n
\n \n

Example activating multiple feature flags

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n
window.EmberDataENV = {\n  FEATURES: {\n    RECORD_DATA_ERRORS: true,\n    RECORD_DATA_STATE: true,\n  }\n}
\n
\n
\n \n

Example activating all feature flags

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n
window.EmberDataENV = {\n  ENABLE_OPTIONAL_FEATURES: true\n}
\n
\n
\n \n

Build Time Configuration

\n

Example activating a single feature flags

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
EMBER_DATA_FEATURE_OVERRIDE=REQUEST_SERVICE ember build
\n
\n
\n \n

Example activating multiple feature flags

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
EMBER_DATA_FEATURE_OVERRIDE=REQUEST_SERVICE,CUSTOM_MODEL_CLASS ember build
\n
\n
\n \n

Example activating all feature flags

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n
EMBER_DATA_FEATURE_OVERRIDE=ENABLE_ALL_OPTIONAL ember build
\n
\n
\n \n

Preparing an Addon to use a Canary Feature

\n

For most addons and most features simple version detection should be\nenough. Using the provided version compatibility helpers from\nember-compatibility-helpers\nthe following can be done:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
if (gte('@ember-data/store', '3.12.0')) {\n\n} else {\n\n}
\n
\n
\n \n

For addons needing more advanced detection babel-plugin-debug-macros\ncan be leveraged to provide code-stripping based on feature presence. For example in your addon's index.js:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n
function debugMacros(features) {\n  let plugins = [\n    [\n      require.resolve('babel-plugin-debug-macros'),\n      {\n        flags: [\n          {\n            source: '<addon-name>/feature-flags',\n            flags: features,\n          },\n        ],\n      },\n      '<addon-name>/canary-features-stripping',\n    ],\n  ];\n\n  return plugins;\n}\n\nmodule.exports = {\n  name: '<addon-name>',\n\n  init() {\n    this._super.init.apply(this, arguments);\n\n    let features;\n    try {\n      features = this.project.require('@ember-data/private-build-infra/src/features')();\n    } catch (e) {\n      features = { CUSTOM_MODEL_CLASS: false };\n    }\n\n    this.options = this.options || {};\n    this.options.babel = this.options.babel || {};\n    // this ensures that the same `@ember-data/canary-features` processing that the various\n    // ember-data addons do is done for this addon\n    this.options.babel.plugins = [...debugMacros(features)];\n  }\n}
\n
\n
\n \n", + "itemtype": "main", + "parent": null, + "publicclasses": [], + "privateclasses": [], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/debug-68bca8ad7e.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/debug-68bca8ad7e.json new file mode 100644 index 000000000..e4ed1718c --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/debug-68bca8ad7e.json @@ -0,0 +1,37 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/debug", + "type": "module", + "attributes": { + "name": "@ember-data/debug", + "submodules": {}, + "elements": {}, + "fors": {}, + "namespaces": {}, + "tag": "main", + "file": "../debug/addon/index.js", + "line": 37, + "description": "

Overview

\n

This package provides the DataAdapter which the Ember Inspector\nuses to subscribe and retrieve information for the data tab in the inspector.

\n

This package adds roughly .6 KB when minified and compressed to your application in production; however,\nyou can opt out of shipping this addon in production via options in ember-cli-build.js

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
let app = new EmberApp(defaults, {\n  emberData: {\n    includeDataAdapterInProduction: false\n  }\n});
\n
\n
\n \n

When using ember-data as a dependency of your app, the default is to ship the inspector support to production.

\n

When not using ember-data as a dependency but instead using EmberData via declaring specific @ember-data/<package>\ndependencies the default is to not ship to production.

\n", + "itemtype": "main", + "parent": null, + "publicclasses": [], + "privateclasses": [ + "InspectorDataAdapter" + ], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/model-0a37a6db52.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/model-0a37a6db52.json new file mode 100644 index 000000000..981c480ea --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/model-0a37a6db52.json @@ -0,0 +1,565 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/model", + "type": "module", + "attributes": { + "name": "@ember-data/model", + "submodules": {}, + "elements": {}, + "fors": { + "@ember-data/model": 1, + "Model": 1 + }, + "namespaces": {}, + "tag": "main", + "file": "../model/addon/-private/model.js", + "line": 105, + "description": "

In EmberData a Model is a class defining the attributes and relationships\n of a specific resource type (model name). In this sense it represents a static "schema".

\n

Data for individual resources fetched from your API is presented\n to the UI via instances of the Models you define.

\n

An instantiated Model is referred to as a record.

\n

When we refer to the ModelClass we are referring to the class definition\n and the static schema methods present on it.

\n

When we refer to a record we refer to a specific class instance presenting\n the resource data for a given type and id.

\n

Defining a Model

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/person.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';\n\nexport default class PersonModel extends Model {\n  @attr name;\n\n  @belongsTo('pet', { inverse: 'owners', async: false }) dog;\n\n  @hasMany('person', { inverse: 'friends', async: true }) friends;\n}
\n
\n
\n \n

modelName convention

\n

By convention, the name of a given model (its type) matches the name\n of the file in the app/models folder and should be lowercase, singular\n and dasherized.

\n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "PromiseManyArray", + "Model" + ], + "privateclasses": [ + "PromiseBelongsTo" + ], + "staticfunctions": { + "@ember-data/model": [ + { + "file": "../model/addon/-private/attr.js", + "line": 27, + "description": "`attr` defines an attribute on a [Model](/ember-data/release/classes/Model).\nBy default, attributes are passed through as-is, however you can specify an\noptional type to have the value automatically transformed.\nEmber Data ships with four basic transform types: `string`, `number`,\n`boolean` and `date`. You can define your own transforms by subclassing\n[Transform](/ember-data/release/classes/Transform).\n\nNote that you cannot use `attr` to define an attribute of `id`.\n\n`attr` takes an optional hash as a second parameter, currently\nsupported options are:\n\n- `defaultValue`: Pass a string or a function to be called to set the attribute\nto a default value if and only if the key is absent from the payload response.\n\nExample\n\n```app/models/user.js\nimport Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n @attr('boolean', { defaultValue: false }) verified;\n}\n```\n\nDefault value can also be a function. This is useful it you want to return\na new object for each attribute.\n\n```app/models/user.js\nimport Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n\n @attr({\n defaultValue() {\n return {};\n }\n })\n settings;\n}\n```\n\nThe `options` hash is passed as second argument to a transforms'\n`serialize` and `deserialize` method. This allows to configure a\ntransformation and adapt the corresponding value, based on the config:\n\n```app/models/post.js\nimport Model, { attr } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @attr('text', {\n uppercase: true\n })\n text;\n}\n```\n\n```app/transforms/text.js\nimport Transform from '@ember-data/serializer/transform';\n\nexport default Transform.extend({\n serialize(value, options) {\n if (options.uppercase) {\n return value.toUpperCase();\n }\n\n return value;\n },\n\n deserialize(value) {\n return value;\n }\n})\n```", + "itemtype": "method", + "name": "attr", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "type", + "description": "the attribute type", + "type": "String|Object" + }, + { + "name": "options", + "description": "a hash of options", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Attribute" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/belongs-to.js", + "line": 11, + "description": "`belongsTo` is used to define One-To-One and One-To-Many\nrelationships on a [Model](/ember-data/release/classes/Model).\n\n\n`belongsTo` takes an optional hash as a second parameter, currently\nsupported options are:\n\n- `async`: A boolean value used to explicitly declare this to be an async relationship. The default is true.\n- `inverse`: A string used to identify the inverse property on a\n related model in a One-To-Many relationship. See [Explicit Inverses](#explicit-inverses)\n- `polymorphic` A boolean value to mark the relationship as polymorphic\n\n#### One-To-One\nTo declare a one-to-one relationship between two models, use\n`belongsTo`:\n\n```app/models/user.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n @belongsTo('profile') profile;\n}\n```\n\n```app/models/profile.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class ProfileModel extends Model {\n @belongsTo('user') user;\n}\n```\n\n#### One-To-Many\nTo declare a one-to-many relationship between two models, use\n`belongsTo` in combination with `hasMany`, like this:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('comment') comments;\n}\n```\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo('post') post;\n}\n```\n\nYou can avoid passing a string as the first parameter. In that case Ember Data\nwill infer the type from the key name.\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo post;\n}\n```\n\nwill lookup for a Post type.\n\n#### Sync relationships\n\nEmber Data resolves sync relationships with the related resources\navailable in its local store, hence it is expected these resources\nto be loaded before or along-side the primary resource.\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo('post', {\n async: false\n })\n post;\n}\n```\n\nIn contrast to async relationship, accessing a sync relationship\nwill always return the record (Model instance) for the existing\nlocal resource, or null. But it will error on access when\na related resource is known to exist and it has not been loaded.\n\n```\nlet post = comment.get('post');\n\n```", + "itemtype": "method", + "name": "belongsTo", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "modelName", + "description": "(optional) type of the relationship", + "type": "String" + }, + { + "name": "options", + "description": "(optional) a hash of options", + "type": "Object" + } + ], + "return": { + "description": "relationship", + "type": "Ember.computed" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/has-many.js", + "line": 10, + "description": "`hasMany` is used to define One-To-Many and Many-To-Many\nrelationships on a [Model](/ember-data/release/classes/Model).\n\n`hasMany` takes an optional hash as a second parameter, currently\nsupported options are:\n\n- `async`: A boolean value used to explicitly declare this to be an async relationship. The default is true.\n- `inverse`: A string used to identify the inverse property on a related model.\n- `polymorphic` A boolean value to mark the relationship as polymorphic\n\n#### One-To-Many\nTo declare a one-to-many relationship between two models, use\n`belongsTo` in combination with `hasMany`, like this:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('comment') comments;\n}\n```\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo('post') post;\n}\n```\n\n#### Many-To-Many\nTo declare a many-to-many relationship between two models, use\n`hasMany`:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('tag') tags;\n}\n```\n\n```app/models/tag.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class TagModel extends Model {\n @hasMany('post') posts;\n}\n```\n\nYou can avoid passing a string as the first parameter. In that case Ember Data\nwill infer the type from the singularized key name.\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany tags;\n}\n```\n\nwill lookup for a Tag type.\n\n#### Explicit Inverses\n\nEmber Data will do its best to discover which relationships map to\none another. In the one-to-many code above, for example, Ember Data\ncan figure out that changing the `comments` relationship should update\nthe `post` relationship on the inverse because post is the only\nrelationship to that model.\n\nHowever, sometimes you may have multiple `belongsTo`/`hasMany` for the\nsame type. You can specify which property on the related model is\nthe inverse using `hasMany`'s `inverse` option:\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo('post') onePost;\n @belongsTo('post') twoPost\n @belongsTo('post') redPost;\n @belongsTo('post') bluePost;\n}\n```\n\n```app/models/post.js\nimport Model from '@ember-data/model';\nimport { hasMany } from '@ember-decorators/data';\n\nexport default class PostModel extends Model {\n @hasMany('comment', {\n inverse: 'redPost'\n })\n comments;\n}\n```\n\nYou can also specify an inverse on a `belongsTo`, which works how\nyou'd expect.\n\n#### Sync relationships\n\nEmber Data resolves sync relationships with the related resources\navailable in its local store, hence it is expected these resources\nto be loaded before or along-side the primary resource.\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('comment', {\n async: false\n })\n comments;\n}\n```\n\nIn contrast to async relationship, accessing a sync relationship\nwill always return a [ManyArray](/ember-data/release/classes/ManyArray) instance\ncontaining the existing local resources. But it will error on access\nwhen any of the known related resources have not been loaded.\n\n```\npost.get('comments').forEach((comment) => {\n\n});\n\n```\n\nIf you are using `links` with sync relationships, you have to use\n`ref.reload` to fetch the resources.", + "itemtype": "method", + "name": "hasMany", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "type", + "description": "(optional) type of the relationship", + "type": "String" + }, + { + "name": "options", + "description": "(optional) a hash of options", + "type": "Object" + } + ], + "return": { + "description": "relationship", + "type": "Ember.computed" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + } + ], + "Model": [ + { + "file": "../model/addon/-private/model.js", + "line": 1965, + "description": "Iterates through the attributes of the model, calling the passed function on each\nattribute.\n\nThe callback method you provide should have the following signature (all\nparameters are optional):\n\n```javascript\nfunction(name, meta);\n```\n\n- `name` the name of the current property in the iteration\n- `meta` the meta object for the attribute property in the iteration\n\nNote that in addition to a callback, you can also pass an optional target\nobject that will be set as `this` on the context.\n\nExample\n\n```javascript\nimport Model, { attr } from '@ember-data/model';\n\nclass PersonModel extends Model {\n @attr('string') firstName;\n @attr('string') lastName;\n @attr('date') birthday;\n }\n\nPersonModel.eachAttribute(function(name, meta) {\n console.log(name, meta);\n });\n\n// prints:\n// firstName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"firstName\"}\n// lastName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"lastName\"}\n// birthday {type: \"date\", isAttribute: true, options: Object, parentType: function, name: \"birthday\"}\n```", + "itemtype": "method", + "name": "eachAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "The callback to execute", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Object", + "optional": true + } + ], + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1812, + "description": "Given a callback, iterates over each of the types related to a model,\ninvoking the callback with the related type's class. Each type will be\nreturned just once, regardless of how many different relationships it has\nwith a model.", + "itemtype": "method", + "name": "eachRelatedType", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "callback", + "description": "the callback to invoke", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Any" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1795, + "description": "Given a callback, iterates over each of the relationships in the model,\ninvoking the callback with the name of each relationship and its relationship\ndescriptor.", + "itemtype": "method", + "name": "eachRelationship", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "callback", + "description": "the callback to invoke", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Any" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2015, + "description": "Iterates through the transformedAttributes of the model, calling\nthe passed function on each attribute. Note the callback will not be\ncalled for any attributes that do not have an transformation type.\n\nThe callback method you provide should have the following signature (all\nparameters are optional):\n\n```javascript\nfunction(name, type);\n```\n\n- `name` the name of the current property in the iteration\n- `type` a string containing the name of the type of transformed\napplied to the attribute\n\nNote that in addition to a callback, you can also pass an optional target\nobject that will be set as `this` on the context.\n\nExample\n\n```javascript\nimport Model, { attr } from '@ember-data/model';\n\nlet Person = Model.extend({\n firstName: attr(),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\nPerson.eachTransformedAttribute(function(name, type) {\n console.log(name, type);\n });\n\n// prints:\n// lastName string\n// birthday date\n```", + "itemtype": "method", + "name": "eachTransformedAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "The callback to execute", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Object", + "optional": true + } + ], + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1355, + "description": "Find the relationship which is the inverse of the one asked for.\n\nFor example, if you define models like this:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('message') comments;\n }\n```\n\n```app/models/message.js\nimport Model from '@ember-data/model';\nimport { belongsTo } from '@ember-decorators/data';\n\nexport default class MessageModel extends Model {\n @belongsTo('post') owner;\n }\n```\n\n``` js\nstore.modelFor('post').inverseFor('comments', store) // { type: App.Message, name: 'owner', kind: 'belongsTo' }\nstore.modelFor('message').inverseFor('owner', store) // { type: App.Post, name: 'comments', kind: 'hasMany' }\n```", + "itemtype": "method", + "name": "inverseFor", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "name", + "description": "the name of the relationship", + "type": "String" + }, + { + "name": "store", + "description": "", + "type": "Store" + } + ], + "return": { + "description": "the inverse relationship, or null", + "type": "Object" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2066, + "description": "Returns the name of the model class.", + "itemtype": "method", + "name": "toString", + "access": "public", + "tagname": "", + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1323, + "description": "For a given relationship name, returns the model type of the relationship.\n\nFor example, if you define a model like this:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('comment') comments;\n}\n```\n\nCalling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.", + "itemtype": "method", + "name": "typeForRelationship", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "name", + "description": "the name of the relationship", + "type": "String" + }, + { + "name": "store", + "description": "an instance of Store", + "type": "Store" + } + ], + "return": { + "description": "the type of the relationship, or undefined", + "type": "Model" + }, + "class": "Model", + "module": "@ember-data/model" + } + ] + }, + "allstaticfunctions": { + "@ember-data/model": [ + { + "file": "../model/addon/-private/attr.js", + "line": 27, + "description": "`attr` defines an attribute on a [Model](/ember-data/release/classes/Model).\nBy default, attributes are passed through as-is, however you can specify an\noptional type to have the value automatically transformed.\nEmber Data ships with four basic transform types: `string`, `number`,\n`boolean` and `date`. You can define your own transforms by subclassing\n[Transform](/ember-data/release/classes/Transform).\n\nNote that you cannot use `attr` to define an attribute of `id`.\n\n`attr` takes an optional hash as a second parameter, currently\nsupported options are:\n\n- `defaultValue`: Pass a string or a function to be called to set the attribute\nto a default value if and only if the key is absent from the payload response.\n\nExample\n\n```app/models/user.js\nimport Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n @attr('boolean', { defaultValue: false }) verified;\n}\n```\n\nDefault value can also be a function. This is useful it you want to return\na new object for each attribute.\n\n```app/models/user.js\nimport Model, { attr } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n\n @attr({\n defaultValue() {\n return {};\n }\n })\n settings;\n}\n```\n\nThe `options` hash is passed as second argument to a transforms'\n`serialize` and `deserialize` method. This allows to configure a\ntransformation and adapt the corresponding value, based on the config:\n\n```app/models/post.js\nimport Model, { attr } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @attr('text', {\n uppercase: true\n })\n text;\n}\n```\n\n```app/transforms/text.js\nimport Transform from '@ember-data/serializer/transform';\n\nexport default Transform.extend({\n serialize(value, options) {\n if (options.uppercase) {\n return value.toUpperCase();\n }\n\n return value;\n },\n\n deserialize(value) {\n return value;\n }\n})\n```", + "itemtype": "method", + "name": "attr", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "type", + "description": "the attribute type", + "type": "String|Object" + }, + { + "name": "options", + "description": "a hash of options", + "type": "Object" + } + ], + "return": { + "description": "", + "type": "Attribute" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/belongs-to.js", + "line": 11, + "description": "`belongsTo` is used to define One-To-One and One-To-Many\nrelationships on a [Model](/ember-data/release/classes/Model).\n\n\n`belongsTo` takes an optional hash as a second parameter, currently\nsupported options are:\n\n- `async`: A boolean value used to explicitly declare this to be an async relationship. The default is true.\n- `inverse`: A string used to identify the inverse property on a\n related model in a One-To-Many relationship. See [Explicit Inverses](#explicit-inverses)\n- `polymorphic` A boolean value to mark the relationship as polymorphic\n\n#### One-To-One\nTo declare a one-to-one relationship between two models, use\n`belongsTo`:\n\n```app/models/user.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n @belongsTo('profile') profile;\n}\n```\n\n```app/models/profile.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class ProfileModel extends Model {\n @belongsTo('user') user;\n}\n```\n\n#### One-To-Many\nTo declare a one-to-many relationship between two models, use\n`belongsTo` in combination with `hasMany`, like this:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('comment') comments;\n}\n```\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo('post') post;\n}\n```\n\nYou can avoid passing a string as the first parameter. In that case Ember Data\nwill infer the type from the key name.\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo post;\n}\n```\n\nwill lookup for a Post type.\n\n#### Sync relationships\n\nEmber Data resolves sync relationships with the related resources\navailable in its local store, hence it is expected these resources\nto be loaded before or along-side the primary resource.\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo('post', {\n async: false\n })\n post;\n}\n```\n\nIn contrast to async relationship, accessing a sync relationship\nwill always return the record (Model instance) for the existing\nlocal resource, or null. But it will error on access when\na related resource is known to exist and it has not been loaded.\n\n```\nlet post = comment.get('post');\n\n```", + "itemtype": "method", + "name": "belongsTo", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "modelName", + "description": "(optional) type of the relationship", + "type": "String" + }, + { + "name": "options", + "description": "(optional) a hash of options", + "type": "Object" + } + ], + "return": { + "description": "relationship", + "type": "Ember.computed" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/has-many.js", + "line": 10, + "description": "`hasMany` is used to define One-To-Many and Many-To-Many\nrelationships on a [Model](/ember-data/release/classes/Model).\n\n`hasMany` takes an optional hash as a second parameter, currently\nsupported options are:\n\n- `async`: A boolean value used to explicitly declare this to be an async relationship. The default is true.\n- `inverse`: A string used to identify the inverse property on a related model.\n- `polymorphic` A boolean value to mark the relationship as polymorphic\n\n#### One-To-Many\nTo declare a one-to-many relationship between two models, use\n`belongsTo` in combination with `hasMany`, like this:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('comment') comments;\n}\n```\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo('post') post;\n}\n```\n\n#### Many-To-Many\nTo declare a many-to-many relationship between two models, use\n`hasMany`:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('tag') tags;\n}\n```\n\n```app/models/tag.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class TagModel extends Model {\n @hasMany('post') posts;\n}\n```\n\nYou can avoid passing a string as the first parameter. In that case Ember Data\nwill infer the type from the singularized key name.\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany tags;\n}\n```\n\nwill lookup for a Tag type.\n\n#### Explicit Inverses\n\nEmber Data will do its best to discover which relationships map to\none another. In the one-to-many code above, for example, Ember Data\ncan figure out that changing the `comments` relationship should update\nthe `post` relationship on the inverse because post is the only\nrelationship to that model.\n\nHowever, sometimes you may have multiple `belongsTo`/`hasMany` for the\nsame type. You can specify which property on the related model is\nthe inverse using `hasMany`'s `inverse` option:\n\n```app/models/comment.js\nimport Model, { belongsTo } from '@ember-data/model';\n\nexport default class CommentModel extends Model {\n @belongsTo('post') onePost;\n @belongsTo('post') twoPost\n @belongsTo('post') redPost;\n @belongsTo('post') bluePost;\n}\n```\n\n```app/models/post.js\nimport Model from '@ember-data/model';\nimport { hasMany } from '@ember-decorators/data';\n\nexport default class PostModel extends Model {\n @hasMany('comment', {\n inverse: 'redPost'\n })\n comments;\n}\n```\n\nYou can also specify an inverse on a `belongsTo`, which works how\nyou'd expect.\n\n#### Sync relationships\n\nEmber Data resolves sync relationships with the related resources\navailable in its local store, hence it is expected these resources\nto be loaded before or along-side the primary resource.\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('comment', {\n async: false\n })\n comments;\n}\n```\n\nIn contrast to async relationship, accessing a sync relationship\nwill always return a [ManyArray](/ember-data/release/classes/ManyArray) instance\ncontaining the existing local resources. But it will error on access\nwhen any of the known related resources have not been loaded.\n\n```\npost.get('comments').forEach((comment) => {\n\n});\n\n```\n\nIf you are using `links` with sync relationships, you have to use\n`ref.reload` to fetch the resources.", + "itemtype": "method", + "name": "hasMany", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "type", + "description": "(optional) type of the relationship", + "type": "String" + }, + { + "name": "options", + "description": "(optional) a hash of options", + "type": "Object" + } + ], + "return": { + "description": "relationship", + "type": "Ember.computed" + }, + "class": "@ember-data/model", + "module": "@ember-data/model" + } + ], + "Model": [ + { + "file": "../model/addon/-private/model.js", + "line": 1262, + "description": "Create should only ever be called by the store. To create an instance of a\n`Model` in a dirty state use `store.createRecord`.\n\n To create instances of `Model` in a clean state, use `store.push`", + "itemtype": "method", + "name": "create", + "access": "private", + "tagname": "", + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1965, + "description": "Iterates through the attributes of the model, calling the passed function on each\nattribute.\n\nThe callback method you provide should have the following signature (all\nparameters are optional):\n\n```javascript\nfunction(name, meta);\n```\n\n- `name` the name of the current property in the iteration\n- `meta` the meta object for the attribute property in the iteration\n\nNote that in addition to a callback, you can also pass an optional target\nobject that will be set as `this` on the context.\n\nExample\n\n```javascript\nimport Model, { attr } from '@ember-data/model';\n\nclass PersonModel extends Model {\n @attr('string') firstName;\n @attr('string') lastName;\n @attr('date') birthday;\n }\n\nPersonModel.eachAttribute(function(name, meta) {\n console.log(name, meta);\n });\n\n// prints:\n// firstName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"firstName\"}\n// lastName {type: \"string\", isAttribute: true, options: Object, parentType: function, name: \"lastName\"}\n// birthday {type: \"date\", isAttribute: true, options: Object, parentType: function, name: \"birthday\"}\n```", + "itemtype": "method", + "name": "eachAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "The callback to execute", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Object", + "optional": true + } + ], + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1812, + "description": "Given a callback, iterates over each of the types related to a model,\ninvoking the callback with the related type's class. Each type will be\nreturned just once, regardless of how many different relationships it has\nwith a model.", + "itemtype": "method", + "name": "eachRelatedType", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "callback", + "description": "the callback to invoke", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Any" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1795, + "description": "Given a callback, iterates over each of the relationships in the model,\ninvoking the callback with the name of each relationship and its relationship\ndescriptor.", + "itemtype": "method", + "name": "eachRelationship", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "callback", + "description": "the callback to invoke", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Any" + } + ], + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2015, + "description": "Iterates through the transformedAttributes of the model, calling\nthe passed function on each attribute. Note the callback will not be\ncalled for any attributes that do not have an transformation type.\n\nThe callback method you provide should have the following signature (all\nparameters are optional):\n\n```javascript\nfunction(name, type);\n```\n\n- `name` the name of the current property in the iteration\n- `type` a string containing the name of the type of transformed\napplied to the attribute\n\nNote that in addition to a callback, you can also pass an optional target\nobject that will be set as `this` on the context.\n\nExample\n\n```javascript\nimport Model, { attr } from '@ember-data/model';\n\nlet Person = Model.extend({\n firstName: attr(),\n lastName: attr('string'),\n birthday: attr('date')\n });\n\nPerson.eachTransformedAttribute(function(name, type) {\n console.log(name, type);\n });\n\n// prints:\n// lastName string\n// birthday date\n```", + "itemtype": "method", + "name": "eachTransformedAttribute", + "access": "public", + "tagname": "", + "params": [ + { + "name": "callback", + "description": "The callback to execute", + "type": "Function" + }, + { + "name": "binding", + "description": "the value to which the callback's `this` should be bound", + "type": "Object", + "optional": true + } + ], + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1355, + "description": "Find the relationship which is the inverse of the one asked for.\n\nFor example, if you define models like this:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('message') comments;\n }\n```\n\n```app/models/message.js\nimport Model from '@ember-data/model';\nimport { belongsTo } from '@ember-decorators/data';\n\nexport default class MessageModel extends Model {\n @belongsTo('post') owner;\n }\n```\n\n``` js\nstore.modelFor('post').inverseFor('comments', store) // { type: App.Message, name: 'owner', kind: 'belongsTo' }\nstore.modelFor('message').inverseFor('owner', store) // { type: App.Post, name: 'comments', kind: 'hasMany' }\n```", + "itemtype": "method", + "name": "inverseFor", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "name", + "description": "the name of the relationship", + "type": "String" + }, + { + "name": "store", + "description": "", + "type": "Store" + } + ], + "return": { + "description": "the inverse relationship, or null", + "type": "Object" + }, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 2066, + "description": "Returns the name of the model class.", + "itemtype": "method", + "name": "toString", + "access": "public", + "tagname": "", + "static": 1, + "class": "Model", + "module": "@ember-data/model" + }, + { + "file": "../model/addon/-private/model.js", + "line": 1323, + "description": "For a given relationship name, returns the model type of the relationship.\n\nFor example, if you define a model like this:\n\n```app/models/post.js\nimport Model, { hasMany } from '@ember-data/model';\n\nexport default class PostModel extends Model {\n @hasMany('comment') comments;\n}\n```\n\nCalling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.", + "itemtype": "method", + "name": "typeForRelationship", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "name", + "description": "the name of the relationship", + "type": "String" + }, + { + "name": "store", + "description": "an instance of Store", + "type": "Store" + } + ], + "return": { + "description": "the type of the relationship, or undefined", + "type": "Model" + }, + "class": "Model", + "module": "@ember-data/model" + } + ] + }, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer-fdd495c39c.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer-fdd495c39c.json new file mode 100644 index 000000000..1c30846cc --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer-fdd495c39c.json @@ -0,0 +1,43 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer", + "type": "module", + "attributes": { + "name": "@ember-data/serializer", + "submodules": {}, + "elements": {}, + "fors": {}, + "namespaces": {}, + "tag": "main", + "file": "../store/addon/-private/ts-interfaces/minimum-serializer-interface.ts", + "line": 15, + "description": "

Overview

\n

In order to properly manage and present your data, EmberData\nneeds to understand the structure of data it receives.

\n

Serializers convert data between the server's API format and\nthe format EmberData understands.

\n

Data received from an API response is normalized into\nJSON:API (the format used internally\nby EmberData), while data sent to an API is serialized\ninto the format the API expects.

\n

Implementing a Serializer

\n

There are only two required serializer methods, one for\nnormalizing data from the server API format into JSON:API, and\nanother for serializing records via Snapshots into the expected\nserver API format.

\n

To implement a serializer, export a class that conforms to the structure\ndescribed by the MinimumSerializerInterface\nfrom the app/serializers/ directory. An example is below.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n
import EmberObject from '@ember/object';\n\nexport default class ApplicationSerializer extends EmberObject {\n  normalizeResponse(store, schema, rawPayload) {\n    return rawPayload;\n  }\n\n  serialize(snapshot, options) {\n    const serializedResource = {\n      id: snapshot.id,\n      type: snapshot.modelName,\n      attributes: snapshot.attributes()\n    };\n\n    return serializedResource;\n  }\n}
\n
\n
\n \n

Serializer Resolution

\n

store.serializerFor(name) will lookup serializers defined in\napp/serializers/ and return an instance. If no serializer is found, an\nerror will be thrown.

\n

serializerFor first attempts to find a serializer with an exact match on name,\nthen falls back to checking for the presence of a serializer named application.

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n
store.serializerFor('author');\n\n// lookup paths (in order) =>\n//   app/serializers/author.js\n//   app/serializers/application.js
\n
\n
\n \n

Most requests in EmberData are made with respect to a particular type (or modelName)\n(e.g., "get me the full collection of books" or "get me the employee whose id is 37"). We\nrefer to this as the primary resource type.

\n

Typically serializerFor will be used to find a serializer with a name matching that of the primary\nresource type for the request, falling back to the application serializer for those types that\ndo not have a defined serializer. This is often described as a per-model or per-type strategy\nfor defining serializers. However, because APIs rarely format payloads per-type but rather\nper-API-version, this may not be a desired strategy.

\n

It is recommended that applications define only a single application adapter and serializer\nwhere possible.

\n

If you have multiple API formats and the per-type strategy is not viable, one strategy is to\nwrite an application adapter and serializer that make use of options to specify the desired\nformat when making a request.

\n

Using a Serializer

\n

Any serializer in app/serializers/ can be looked up by name using store.serializerFor(name).

\n

Default Serializers

\n

For applications whose APIs are very close to or exactly the REST format or JSON:API\nformat the @ember-data/serializer package contains implementations these applications can\nextend. It also contains a simple JSONSerializer for serializing to/from very basic JSON objects.

\n

Many applications will find writing their own serializer to be more performant and less\ncomplex than extending these classes even when their API format is very close to that expected\nby these serializers.

\n

It is recommended that apps write their own serializer to best suit the needs of their API and\napplication.

\n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "BooleanTransform", + "DateTransform", + "NumberTransform", + "StringTransform", + "Transform", + "Serializer", + "MinimumSerializerInterface" + ], + "privateclasses": [], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/json-a8fe5001d6.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/json-a8fe5001d6.json new file mode 100644 index 000000000..39259ccc4 --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/json-a8fe5001d6.json @@ -0,0 +1,37 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer/json", + "type": "module", + "attributes": { + "name": "@ember-data/serializer/json", + "submodules": {}, + "elements": {}, + "fors": {}, + "namespaces": {}, + "tag": "main", + "file": "../serializer/addon/json.js", + "line": 16, + "description": "

Ember Data 2.0 Serializer:

\n

In Ember Data a Serializer is used to serialize and deserialize\nrecords when they are transferred in and out of an external source.\nThis process involves normalizing property names, transforming\nattribute values and serializing relationships.

\n

By default, Ember Data uses and recommends the JSONAPISerializer.

\n

JSONSerializer is useful for simpler or legacy backends that may\nnot support the http://jsonapi.org/ spec.

\n

For example, given the following User model and JSON payload:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/user.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';\n\nexport default class UserModel extends Model {\n  @hasMany('user') friends;\n  @belongsTo('location') house;\n\n  @attr('string') name;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n
{\n  id: 1,\n  name: 'Sebastian',\n  friends: [3, 4],\n  links: {\n    house: '/houses/lefkada'\n  }\n}
\n
\n
\n \n

JSONSerializer will normalize the JSON payload to the JSON API format that the\nEmber Data store expects.

\n

You can customize how JSONSerializer processes its payload by passing options in\nthe attrs hash or by subclassing the JSONSerializer and overriding hooks:

\n
    \n
  • To customize how a single record is normalized, use the normalize hook.
  • \n
  • To customize how JSONSerializer normalizes the whole server response, use the\nnormalizeResponse hook.
  • \n
  • To customize how JSONSerializer normalizes a specific response from the server,\nuse one of the many specific normalizeResponse hooks.
  • \n
  • To customize how JSONSerializer normalizes your id, attributes or relationships,\nuse the extractId, extractAttributes and extractRelationships hooks.
  • \n
\n

The JSONSerializer normalization process follows these steps:

\n
    \n
  1. normalizeResponse
      \n
    • entry method to the serializer.
    • \n
    \n
  2. \n
  3. normalizeCreateRecordResponse
      \n
    • a normalizeResponse for a specific operation is called.
    • \n
    \n
  4. \n
  5. normalizeSingleResponse|normalizeArrayResponse
      \n
    • for methods like createRecord we expect a single record back, while for methods like findAll we expect multiple records back.
    • \n
    \n
  6. \n
  7. normalize
      \n
    • normalizeArrayResponse iterates and calls normalize for each of its records while normalizeSingle\ncalls it once. This is the method you most likely want to subclass.
    • \n
    \n
  8. \n
  9. extractId | extractAttributes | extractRelationships
      \n
    • normalize delegates to these methods to\nturn the record payload into the JSON API format.
    • \n
    \n
  10. \n
\n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "JSONSerializer" + ], + "privateclasses": [], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/json-api-b473fed6b9.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/json-api-b473fed6b9.json new file mode 100644 index 000000000..b4238eaa6 --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/json-api-b473fed6b9.json @@ -0,0 +1,37 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer/json-api", + "type": "module", + "attributes": { + "name": "@ember-data/serializer/json-api", + "submodules": {}, + "elements": {}, + "fors": {}, + "namespaces": {}, + "tag": "main", + "file": "../serializer/addon/json-api.js", + "line": 15, + "description": "

Ember Data 2.0 Serializer:

\n

In Ember Data a Serializer is used to serialize and deserialize\nrecords when they are transferred in and out of an external source.\nThis process involves normalizing property names, transforming\nattribute values and serializing relationships.

\n

JSONAPISerializer supports the http://jsonapi.org/ spec and is the\nserializer recommended by Ember Data.

\n

This serializer normalizes a JSON API payload that looks like:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/player.js
1\n2\n3\n4\n5\n6\n7\n8\n
import Model, { attr, belongsTo } from '@ember-data/model';\n\nexport default class Player extends Model {\n  @attr('string') name;\n  @attr('string') skill;\n  @attr('number') gamesPlayed;\n  @belongsTo('club') club;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/models/club.js
1\n2\n3\n4\n5\n6\n7\n
import Model, { attr, hasMany } from '@ember-data/model';\n\nexport default class Club extends Model {\n  @attr('string') name;\n  @attr('string') location;\n  @hasMany('player') players;\n}
\n
\n
\n \n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n
  {\n    "data": [\n      {\n        "attributes": {\n          "name": "Benfica",\n          "location": "Portugal"\n        },\n        "id": "1",\n        "relationships": {\n          "players": {\n            "data": [\n              {\n                "id": "3",\n                "type": "players"\n              }\n            ]\n          }\n        },\n        "type": "clubs"\n      }\n    ],\n    "included": [\n      {\n        "attributes": {\n          "name": "Eusebio Silva Ferreira",\n          "skill": "Rocket shot",\n          "games-played": 431\n        },\n        "id": "3",\n        "relationships": {\n          "club": {\n            "data": {\n              "id": "1",\n              "type": "clubs"\n            }\n          }\n        },\n        "type": "players"\n      }\n    ]\n  }
\n
\n
\n \n

to the format that the Ember Data store expects.

\n

Customizing meta

\n

Since a JSON API Document can have meta defined in multiple locations you can\nuse the specific serializer hooks if you need to customize the meta.

\n

One scenario would be to camelCase the meta keys of your payload. The example\nbelow shows how this could be done using normalizeArrayResponse and\nextractRelationship.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n
import JSONAPISerializer from '@ember-data/serializer/json-api';\n\nexport default class ApplicationSerializer extends JSONAPISerializer {\n  normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {\n    let normalizedDocument = super.normalizeArrayResponse(...arguments);\n\n    // Customize document meta\n    normalizedDocument.meta = camelCaseKeys(normalizedDocument.meta);\n\n    return normalizedDocument;\n  }\n\n  extractRelationship(relationshipHash) {\n    let normalizedRelationship = super.extractRelationship(...arguments);\n\n    // Customize relationship meta\n    normalizedRelationship.meta = camelCaseKeys(normalizedRelationship.meta);\n\n    return normalizedRelationship;\n  }\n}
\n
\n
\n \n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "JSONAPISerializer" + ], + "privateclasses": [], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/rest-6dcd17b48d.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/rest-6dcd17b48d.json new file mode 100644 index 000000000..737d2a654 --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/serializer/rest-6dcd17b48d.json @@ -0,0 +1,38 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/serializer/rest", + "type": "module", + "attributes": { + "name": "@ember-data/serializer/rest", + "submodules": {}, + "elements": {}, + "fors": {}, + "namespaces": {}, + "tag": "main", + "file": "../serializer/addon/rest.js", + "line": 18, + "description": "

Normally, applications will use the RESTSerializer by implementing\nthe normalize method.

\n

This allows you to do whatever kind of munging you need and is\nespecially useful if your server is inconsistent and you need to\ndo munging differently for many different kinds of responses.

\n

See the normalize documentation for more information.

\n

Across the Board Normalization

\n

There are also a number of hooks that you might find useful to define\nacross-the-board rules for your payload. These rules will be useful\nif your server is consistent, or if you're building an adapter for\nan infrastructure service, like Firebase, and want to encode service\nconventions.

\n

For example, if all of your keys are underscored and all-caps, but\notherwise consistent with the names you use in your models, you\ncan implement across-the-board rules for how to convert an attribute\nname in your model to a key in your JSON.

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/serializers/application.js
1\n2\n3\n4\n5\n6\n7\n8\n
import RESTSerializer from '@ember-data/serializer/rest';\nimport { underscore } from '@ember/string';\n\nexport default class ApplicationSerializer extends RESTSerializer {\n  keyForAttribute(attr, method) {\n    return underscore(attr).toUpperCase();\n  }\n}
\n
\n
\n \n

You can also implement keyForRelationship, which takes the name\nof the relationship as the first parameter, the kind of\nrelationship (hasMany or belongsTo) as the second parameter, and\nthe method (serialize or deserialize) as the third parameter.

\n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "EmbeddedRecordsMixin", + "RESTSerializer" + ], + "privateclasses": [], + "staticfunctions": {}, + "allstaticfunctions": {}, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/store-173b52ab7d.json b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/store-173b52ab7d.json new file mode 100644 index 000000000..165115740 --- /dev/null +++ b/json-docs/ember-data/3.28.13/modules/ember-data-3.28.13-@ember-data/store-173b52ab7d.json @@ -0,0 +1,296 @@ +{ + "data": { + "id": "ember-data-3.28.13-@ember-data/store", + "type": "module", + "attributes": { + "name": "@ember-data/store", + "submodules": {}, + "elements": {}, + "fors": { + "@ember-data/store": 1 + }, + "namespaces": {}, + "tag": "main", + "file": "../store/addon/-private/ts-interfaces/record-data-store-wrapper.ts", + "line": 10, + "description": "

The store contains all of the data for records loaded from the server.\nIt is also responsible for creating instances of Model that wrap\nthe individual data for a record, so that they can be bound to in your\nHandlebars templates.

\n

Define your application's store like this:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/services/store.js
1\n2\n3\n
import Store from '@ember-data/store';\n\nexport default class MyStore extends Store {}
\n
\n
\n \n

Most Ember.js applications will only have a single Store that is\nautomatically created by their Ember.Application.

\n

You can retrieve models from the store in several ways. To retrieve a record\nfor a specific id, use Store's findRecord() method:

\n
\n
\n
\n \n \n \n \n \n \n \n
1\n2\n
store.findRecord('person', 123).then(function (person) {\n});
\n
\n
\n \n

By default, the store will talk to your backend using a standard\nREST mechanism. You can customize how the store talks to your\nbackend by specifying a custom adapter:

\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n
app/adapters/application.js
1\n2\n3\n4\n
import Adapter from '@ember-data/adapter';\n\nexport default class ApplicationAdapter extends Adapter {\n}
\n
\n
\n \n

You can learn more about writing a custom adapter by reading the Adapter\ndocumentation.

\n

Store createRecord() vs. push() vs. pushPayload()

\n

The store provides multiple ways to create new record objects. They have\nsome subtle differences in their use which are detailed below:

\n

createRecord is used for creating new\nrecords on the client side. This will return a new record in the\ncreated.uncommitted state. In order to persist this record to the\nbackend, you will need to call record.save().

\n

push is used to notify Ember Data's store of new or\nupdated records that exist in the backend. This will return a record\nin the loaded.saved state. The primary use-case for store#push is\nto notify Ember Data about record updates (full or partial) that happen\noutside of the normal adapter methods (for example\nSSE or Web\nSockets).

\n

pushPayload is a convenience wrapper for\nstore#push that will deserialize payloads if the\nSerializer implements a pushPayload method.

\n

Note: When creating a new record using any of the above methods\nEmber Data will update RecordArrays such as those returned by\nstore#peekAll() or store#findAll(). This means any\ndata bindings or computed properties that depend on the RecordArray\nwill automatically be synced to include the new or updated record\nvalues.

\n", + "itemtype": "main", + "parent": null, + "publicclasses": [ + "ManyArray", + "Errors", + "IdentifierCache", + "AdapterPopulatedRecordArray", + "RecordArray", + "BelongsToReference", + "HasManyReference", + "RecordReference", + "Reference", + "Store", + "PromiseArray", + "PromiseObject", + "SnapshotRecordArray", + "Snapshot", + "StableRecordIdentifier", + "RecordDataStoreWrapper" + ], + "privateclasses": [ + "FetchManager" + ], + "staticfunctions": { + "@ember-data/store": [ + { + "file": "../store/addon/-private/system/normalize-model-name.ts", + "line": 10, + "description": "This method normalizes a modelName into the format Ember Data uses\ninternally by dasherizing it.", + "itemtype": "method", + "name": "normalizeModelName", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalizedModelName", + "type": "String" + }, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/store/internal-model-factory.ts", + "line": 32, + "description": "Retrieves the unique referentially-stable RecordIdentifier assigned to the given\nrecord instance.", + "itemtype": "method", + "name": "recordIdentifierFor", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "record", + "description": "a record instance previously obstained from the store.", + "type": "Object" + } + ], + "return": { + "description": "" + }, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 199, + "description": "Configure a callback for when the identifier cache is going to release an identifier.\n\nThis configuration MUST occur prior to the store instance being created.\n\n```js\nimport { setIdentifierForgetMethod } from '@ember-data/store';\n```\n\nTakes method which can expect to receive an existing `Identifier` that should be eliminated\nfrom any secondary lookup tables or caches that the user has populated for it.", + "itemtype": "method", + "name": "setIdentifierForgetMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 111, + "description": "Configures how unique identifier lid strings are generated by @ember-data/store.\n\nThis configuration MUST occur prior to the store instance being created.\n\nTakes a method which can expect to receive various data as its first argument\nand the name of a bucket as its second argument. Currently the second\nargument will always be `record` data should conform to a `json-api`\n`Resource` interface, but will be the normalized json data for a single\nresource that has been given to the store.\n\nThe method must return a unique (to at-least the given bucket) string identifier\nfor the given data as a string to be used as the `lid` of an `Identifier` token.\n\nThis method will only be called by either `getOrCreateRecordIdentifier` or\n`createIdentifierForNewRecord` when an identifier for the supplied data\nis not already known via `lid` or `type + id` combo and one needs to be\ngenerated or retrieved from a proprietary cache.\n\n`data` will be the same data argument provided to `getOrCreateRecordIdentifier`\nand in the `createIdentifierForNewRecord` case will be an object with\nonly `type` as a key.\n\n```ts\nimport { setIdentifierGenerationMethod } form '@ember-data/store';\n\nexport function initialize(applicationInstance) {\n // note how `count` here is now scoped to the application instance\n // for our generation method by being inside the closure provided\n // by the initialize function\n let count = 0;\n\n setIdentifierGenerationMethod((resource, bucket) => {\n return resource.lid || `my-key-${count++}`;\n });\n}\n\nexport default {\n name: 'configure-ember-data-identifiers',\n initialize\n};\n```", + "itemtype": "method", + "name": "setIdentifierGenerationMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 219, + "description": "Configure a callback for when the identifier cache is being torn down.\n\nThis configuration MUST occur prior to the store instance being created.\n\n```js\nimport { setIdentifierResetMethod } from '@ember-data/store';\n```\n\nTakes a method which can expect to be called when the parent application is destroyed.\n\nIf you have properly used a WeakMap to encapsulate the state of your customization\nto the application instance, you may not need to implement the `resetMethod`.", + "itemtype": "method", + "name": "setIdentifierResetMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 162, + "description": "Configure a callback for when the identifier cache encounters new resource\ndata for an existing resource.\n\nThis configuration MUST occur prior to the store instance being created.\n\n```js\nimport { setIdentifierUpdateMethod } from '@ember-data/store';\n```\n\nTakes a method which can expect to receive an existing `Identifier` alongside\nsome new data to consider as a second argument. This is an opportunity\nfor secondary lookup tables and caches associated with the identifier\nto be amended.\n\nThis method is called everytime `updateRecordIdentifier` is called and\n with the same arguments. It provides the opportunity to update secondary\n lookup tables for existing identifiers.\n\nIt will always be called after an identifier created with `createIdentifierForNewRecord`\n has been committed, or after an update to the `record` a `RecordIdentifier`\n is assigned to has been committed. Committed here meaning that the server\n has acknowledged the update (for instance after a call to `.save()`)\n\nIf `id` has not previously existed, it will be assigned to the `Identifier`\n prior to this `UpdateMethod` being called; however, calls to the parent method\n `updateRecordIdentifier` that attempt to change the `id` or calling update\n without providing an `id` when one is missing will throw an error.", + "itemtype": "method", + "name": "setIdentifierUpdateMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + } + ] + }, + "allstaticfunctions": { + "@ember-data/store": [ + { + "file": "../store/addon/-private/system/normalize-model-name.ts", + "line": 10, + "description": "This method normalizes a modelName into the format Ember Data uses\ninternally by dasherizing it.", + "itemtype": "method", + "name": "normalizeModelName", + "static": 1, + "access": "public", + "tagname": "", + "params": [ + { + "name": "modelName", + "description": "", + "type": "String" + } + ], + "return": { + "description": "normalizedModelName", + "type": "String" + }, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/system/store/internal-model-factory.ts", + "line": 32, + "description": "Retrieves the unique referentially-stable RecordIdentifier assigned to the given\nrecord instance.", + "itemtype": "method", + "name": "recordIdentifierFor", + "access": "public", + "tagname": "", + "static": 1, + "params": [ + { + "name": "record", + "description": "a record instance previously obstained from the store.", + "type": "Object" + } + ], + "return": { + "description": "" + }, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 199, + "description": "Configure a callback for when the identifier cache is going to release an identifier.\n\nThis configuration MUST occur prior to the store instance being created.\n\n```js\nimport { setIdentifierForgetMethod } from '@ember-data/store';\n```\n\nTakes method which can expect to receive an existing `Identifier` that should be eliminated\nfrom any secondary lookup tables or caches that the user has populated for it.", + "itemtype": "method", + "name": "setIdentifierForgetMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 111, + "description": "Configures how unique identifier lid strings are generated by @ember-data/store.\n\nThis configuration MUST occur prior to the store instance being created.\n\nTakes a method which can expect to receive various data as its first argument\nand the name of a bucket as its second argument. Currently the second\nargument will always be `record` data should conform to a `json-api`\n`Resource` interface, but will be the normalized json data for a single\nresource that has been given to the store.\n\nThe method must return a unique (to at-least the given bucket) string identifier\nfor the given data as a string to be used as the `lid` of an `Identifier` token.\n\nThis method will only be called by either `getOrCreateRecordIdentifier` or\n`createIdentifierForNewRecord` when an identifier for the supplied data\nis not already known via `lid` or `type + id` combo and one needs to be\ngenerated or retrieved from a proprietary cache.\n\n`data` will be the same data argument provided to `getOrCreateRecordIdentifier`\nand in the `createIdentifierForNewRecord` case will be an object with\nonly `type` as a key.\n\n```ts\nimport { setIdentifierGenerationMethod } form '@ember-data/store';\n\nexport function initialize(applicationInstance) {\n // note how `count` here is now scoped to the application instance\n // for our generation method by being inside the closure provided\n // by the initialize function\n let count = 0;\n\n setIdentifierGenerationMethod((resource, bucket) => {\n return resource.lid || `my-key-${count++}`;\n });\n}\n\nexport default {\n name: 'configure-ember-data-identifiers',\n initialize\n};\n```", + "itemtype": "method", + "name": "setIdentifierGenerationMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 219, + "description": "Configure a callback for when the identifier cache is being torn down.\n\nThis configuration MUST occur prior to the store instance being created.\n\n```js\nimport { setIdentifierResetMethod } from '@ember-data/store';\n```\n\nTakes a method which can expect to be called when the parent application is destroyed.\n\nIf you have properly used a WeakMap to encapsulate the state of your customization\nto the application instance, you may not need to implement the `resetMethod`.", + "itemtype": "method", + "name": "setIdentifierResetMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + }, + { + "file": "../store/addon/-private/ts-interfaces/identifier.ts", + "line": 162, + "description": "Configure a callback for when the identifier cache encounters new resource\ndata for an existing resource.\n\nThis configuration MUST occur prior to the store instance being created.\n\n```js\nimport { setIdentifierUpdateMethod } from '@ember-data/store';\n```\n\nTakes a method which can expect to receive an existing `Identifier` alongside\nsome new data to consider as a second argument. This is an opportunity\nfor secondary lookup tables and caches associated with the identifier\nto be amended.\n\nThis method is called everytime `updateRecordIdentifier` is called and\n with the same arguments. It provides the opportunity to update secondary\n lookup tables for existing identifiers.\n\nIt will always be called after an identifier created with `createIdentifierForNewRecord`\n has been committed, or after an update to the `record` a `RecordIdentifier`\n is assigned to has been committed. Committed here meaning that the server\n has acknowledged the update (for instance after a call to `.save()`)\n\nIf `id` has not previously existed, it will be assigned to the `Identifier`\n prior to this `UpdateMethod` being called; however, calls to the parent method\n `updateRecordIdentifier` that attempt to change the `id` or calling update\n without providing an `id` when one is missing will throw an error.", + "itemtype": "method", + "name": "setIdentifierUpdateMethod", + "params": [ + { + "name": "method", + "description": "" + } + ], + "access": "public", + "tagname": "", + "static": 1, + "class": "@ember-data/store", + "module": "@ember-data/store" + } + ] + }, + "version": "3.28.13" + }, + "relationships": { + "classes": { + "data": [] + }, + "project-version": { + "data": { + "id": "ember-data-3.28.13", + "type": "project-version" + } + } + } + } +} \ No newline at end of file diff --git a/rev-index/ember-data-3.28.13.json b/rev-index/ember-data-3.28.13.json index 85c1ba751..f40b1053f 100644 --- a/rev-index/ember-data-3.28.13.json +++ b/rev-index/ember-data-3.28.13.json @@ -1 +1 @@ -{"data":{"id":"ember-data-3.28.13","type":"project-version","attributes":{"version":"3.28.13"},"relationships":{"classes":{"data":[{"id":"ember-data-3.28.13-BuildURLMixin","type":"class"},{"id":"ember-data-3.28.13-AdapterError","type":"class"},{"id":"ember-data-3.28.13-InvalidError","type":"class"},{"id":"ember-data-3.28.13-TimeoutError","type":"class"},{"id":"ember-data-3.28.13-AbortError","type":"class"},{"id":"ember-data-3.28.13-UnauthorizedError","type":"class"},{"id":"ember-data-3.28.13-ForbiddenError","type":"class"},{"id":"ember-data-3.28.13-NotFoundError","type":"class"},{"id":"ember-data-3.28.13-ConflictError","type":"class"},{"id":"ember-data-3.28.13-ServerError","type":"class"},{"id":"ember-data-3.28.13-Adapter","type":"class"},{"id":"ember-data-3.28.13-JSONAPIAdapter","type":"class"},{"id":"ember-data-3.28.13-RESTAdapter","type":"class"},{"id":"ember-data-3.28.13-InspectorDataAdapter","type":"class"},{"id":"ember-data-3.28.13-ManyArray","type":"class"},{"id":"ember-data-3.28.13-PromiseBelongsTo","type":"class"},{"id":"ember-data-3.28.13-PromiseManyArray","type":"class"},{"id":"ember-data-3.28.13-Errors","type":"class"},{"id":"ember-data-3.28.13-Model","type":"class"},{"id":"ember-data-3.28.13-RecordDataDefault","type":"class"},{"id":"ember-data-3.28.13-BooleanTransform","type":"class"},{"id":"ember-data-3.28.13-DateTransform","type":"class"},{"id":"ember-data-3.28.13-NumberTransform","type":"class"},{"id":"ember-data-3.28.13-StringTransform","type":"class"},{"id":"ember-data-3.28.13-Transform","type":"class"},{"id":"ember-data-3.28.13-EmbeddedRecordsMixin","type":"class"},{"id":"ember-data-3.28.13-Serializer","type":"class"},{"id":"ember-data-3.28.13-JSONAPISerializer","type":"class"},{"id":"ember-data-3.28.13-JSONSerializer","type":"class"},{"id":"ember-data-3.28.13-RESTSerializer","type":"class"},{"id":"ember-data-3.28.13-IdentifierCache","type":"class"},{"id":"ember-data-3.28.13-AdapterPopulatedRecordArray","type":"class"},{"id":"ember-data-3.28.13-RecordArray","type":"class"},{"id":"ember-data-3.28.13-BelongsToReference","type":"class"},{"id":"ember-data-3.28.13-HasManyReference","type":"class"},{"id":"ember-data-3.28.13-RecordReference","type":"class"},{"id":"ember-data-3.28.13-Reference","type":"class"},{"id":"ember-data-3.28.13-Store","type":"class"},{"id":"ember-data-3.28.13-FetchManager","type":"class"},{"id":"ember-data-3.28.13-PromiseArray","type":"class"},{"id":"ember-data-3.28.13-PromiseObject","type":"class"},{"id":"ember-data-3.28.13-SnapshotRecordArray","type":"class"},{"id":"ember-data-3.28.13-Snapshot","type":"class"},{"id":"ember-data-3.28.13-StableRecordIdentifier","type":"class"},{"id":"ember-data-3.28.13-MinimumAdapterInterface","type":"class"},{"id":"ember-data-3.28.13-MinimumSerializerInterface","type":"class"},{"id":"ember-data-3.28.13-RecordDataStoreWrapper","type":"class"}]},"namespaces":{"data":[]},"modules":{"data":[{"id":"ember-data-3.28.13-@ember-data/adapter","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/error","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/json-api","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/rest","type":"module"},{"id":"ember-data-3.28.13-@ember-data/canary-features","type":"module"},{"id":"ember-data-3.28.13-@ember-data/debug","type":"module"},{"id":"ember-data-3.28.13-@ember-data/store","type":"module"},{"id":"ember-data-3.28.13-@ember-data/model","type":"module"},{"id":"ember-data-3.28.13-@ember-data/deprecations","type":"module"},{"id":"ember-data-3.28.13-@ember-data/record-data","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/rest","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/json-api","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/json","type":"module"}]},"project":{"data":{"id":"ember-data","type":"project"}},"private-classes":{"data":[{"id":"ember-data-3.28.13-InspectorDataAdapter","type":"class"},{"id":"ember-data-3.28.13-PromiseBelongsTo","type":"class"},{"id":"ember-data-3.28.13-FetchManager","type":"class"}]},"public-classes":{"data":[{"id":"ember-data-3.28.13-BuildURLMixin","type":"class"},{"id":"ember-data-3.28.13-AdapterError","type":"class"},{"id":"ember-data-3.28.13-InvalidError","type":"class"},{"id":"ember-data-3.28.13-TimeoutError","type":"class"},{"id":"ember-data-3.28.13-AbortError","type":"class"},{"id":"ember-data-3.28.13-UnauthorizedError","type":"class"},{"id":"ember-data-3.28.13-ForbiddenError","type":"class"},{"id":"ember-data-3.28.13-NotFoundError","type":"class"},{"id":"ember-data-3.28.13-ConflictError","type":"class"},{"id":"ember-data-3.28.13-ServerError","type":"class"},{"id":"ember-data-3.28.13-Adapter","type":"class"},{"id":"ember-data-3.28.13-JSONAPIAdapter","type":"class"},{"id":"ember-data-3.28.13-RESTAdapter","type":"class"},{"id":"ember-data-3.28.13-ManyArray","type":"class"},{"id":"ember-data-3.28.13-PromiseManyArray","type":"class"},{"id":"ember-data-3.28.13-Errors","type":"class"},{"id":"ember-data-3.28.13-Model","type":"class"},{"id":"ember-data-3.28.13-RecordDataDefault","type":"class"},{"id":"ember-data-3.28.13-BooleanTransform","type":"class"},{"id":"ember-data-3.28.13-DateTransform","type":"class"},{"id":"ember-data-3.28.13-NumberTransform","type":"class"},{"id":"ember-data-3.28.13-StringTransform","type":"class"},{"id":"ember-data-3.28.13-Transform","type":"class"},{"id":"ember-data-3.28.13-EmbeddedRecordsMixin","type":"class"},{"id":"ember-data-3.28.13-Serializer","type":"class"},{"id":"ember-data-3.28.13-JSONAPISerializer","type":"class"},{"id":"ember-data-3.28.13-JSONSerializer","type":"class"},{"id":"ember-data-3.28.13-RESTSerializer","type":"class"},{"id":"ember-data-3.28.13-IdentifierCache","type":"class"},{"id":"ember-data-3.28.13-AdapterPopulatedRecordArray","type":"class"},{"id":"ember-data-3.28.13-RecordArray","type":"class"},{"id":"ember-data-3.28.13-BelongsToReference","type":"class"},{"id":"ember-data-3.28.13-HasManyReference","type":"class"},{"id":"ember-data-3.28.13-RecordReference","type":"class"},{"id":"ember-data-3.28.13-Reference","type":"class"},{"id":"ember-data-3.28.13-Store","type":"class"},{"id":"ember-data-3.28.13-PromiseArray","type":"class"},{"id":"ember-data-3.28.13-PromiseObject","type":"class"},{"id":"ember-data-3.28.13-SnapshotRecordArray","type":"class"},{"id":"ember-data-3.28.13-Snapshot","type":"class"},{"id":"ember-data-3.28.13-StableRecordIdentifier","type":"class"},{"id":"ember-data-3.28.13-MinimumAdapterInterface","type":"class"},{"id":"ember-data-3.28.13-MinimumSerializerInterface","type":"class"},{"id":"ember-data-3.28.13-RecordDataStoreWrapper","type":"class"}]},"private-namespaces":{"data":[]},"public-namespaces":{"data":[]},"private-modules":{"data":[]},"public-modules":{"data":[{"id":"ember-data-3.28.13-@ember-data/adapter","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/error","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/json-api","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/rest","type":"module"},{"id":"ember-data-3.28.13-@ember-data/canary-features","type":"module"},{"id":"ember-data-3.28.13-@ember-data/debug","type":"module"},{"id":"ember-data-3.28.13-@ember-data/store","type":"module"},{"id":"ember-data-3.28.13-@ember-data/model","type":"module"},{"id":"ember-data-3.28.13-@ember-data/deprecations","type":"module"},{"id":"ember-data-3.28.13-@ember-data/record-data","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/rest","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/json-api","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/json","type":"module"}]}}},"meta":{"class":{"ember-data-3.28.13-BuildURLMixin":"ember-data-3.28.13-BuildURLMixin-1a657c7ff1","ember-data-3.28.13-AdapterError":"ember-data-3.28.13-AdapterError-83a7188262","ember-data-3.28.13-InvalidError":"ember-data-3.28.13-InvalidError-55efc11025","ember-data-3.28.13-TimeoutError":"ember-data-3.28.13-TimeoutError-3a97cd3d01","ember-data-3.28.13-AbortError":"ember-data-3.28.13-AbortError-f2235db04c","ember-data-3.28.13-UnauthorizedError":"ember-data-3.28.13-UnauthorizedError-39f95335c0","ember-data-3.28.13-ForbiddenError":"ember-data-3.28.13-ForbiddenError-956cdba782","ember-data-3.28.13-NotFoundError":"ember-data-3.28.13-NotFoundError-f54a5772f7","ember-data-3.28.13-ConflictError":"ember-data-3.28.13-ConflictError-98876f4bf7","ember-data-3.28.13-ServerError":"ember-data-3.28.13-ServerError-e35abd623a","ember-data-3.28.13-Adapter":"ember-data-3.28.13-Adapter-9a3457dbf9","ember-data-3.28.13-JSONAPIAdapter":"ember-data-3.28.13-JSONAPIAdapter-3a37a523a3","ember-data-3.28.13-RESTAdapter":"ember-data-3.28.13-RESTAdapter-eb4b64f85d","ember-data-3.28.13-InspectorDataAdapter":"ember-data-3.28.13-InspectorDataAdapter-85b38ef2eb","ember-data-3.28.13-ManyArray":"ember-data-3.28.13-ManyArray-1576697bc1","ember-data-3.28.13-PromiseBelongsTo":"ember-data-3.28.13-PromiseBelongsTo-104303fe9e","ember-data-3.28.13-PromiseManyArray":"ember-data-3.28.13-PromiseManyArray-6b84e02579","ember-data-3.28.13-Errors":"ember-data-3.28.13-Errors-d9612f1a4c","ember-data-3.28.13-Model":"ember-data-3.28.13-Model-db6f59d7ce","ember-data-3.28.13-RecordDataDefault":"ember-data-3.28.13-RecordDataDefault-c301edf248","ember-data-3.28.13-BooleanTransform":"ember-data-3.28.13-BooleanTransform-39055b9e38","ember-data-3.28.13-DateTransform":"ember-data-3.28.13-DateTransform-c3f7380043","ember-data-3.28.13-NumberTransform":"ember-data-3.28.13-NumberTransform-37a54a96aa","ember-data-3.28.13-StringTransform":"ember-data-3.28.13-StringTransform-1776ce4cd4","ember-data-3.28.13-Transform":"ember-data-3.28.13-Transform-715d9bac66","ember-data-3.28.13-EmbeddedRecordsMixin":"ember-data-3.28.13-EmbeddedRecordsMixin-49ff3c289c","ember-data-3.28.13-Serializer":"ember-data-3.28.13-Serializer-f215e04bef","ember-data-3.28.13-JSONAPISerializer":"ember-data-3.28.13-JSONAPISerializer-4a00f534e7","ember-data-3.28.13-JSONSerializer":"ember-data-3.28.13-JSONSerializer-5cc20f856d","ember-data-3.28.13-RESTSerializer":"ember-data-3.28.13-RESTSerializer-68622d2c87","ember-data-3.28.13-IdentifierCache":"ember-data-3.28.13-IdentifierCache-a58ba0ffba","ember-data-3.28.13-AdapterPopulatedRecordArray":"ember-data-3.28.13-AdapterPopulatedRecordArray-9bc7cf1d96","ember-data-3.28.13-RecordArray":"ember-data-3.28.13-RecordArray-511211ced1","ember-data-3.28.13-BelongsToReference":"ember-data-3.28.13-BelongsToReference-030a6f0d21","ember-data-3.28.13-HasManyReference":"ember-data-3.28.13-HasManyReference-baf2e78868","ember-data-3.28.13-RecordReference":"ember-data-3.28.13-RecordReference-ae5519c065","ember-data-3.28.13-Reference":"ember-data-3.28.13-Reference-02a0b49a01","ember-data-3.28.13-Store":"ember-data-3.28.13-Store-17028a28d3","ember-data-3.28.13-FetchManager":"ember-data-3.28.13-FetchManager-8996d4eb65","ember-data-3.28.13-PromiseArray":"ember-data-3.28.13-PromiseArray-a081c07520","ember-data-3.28.13-PromiseObject":"ember-data-3.28.13-PromiseObject-e303008768","ember-data-3.28.13-SnapshotRecordArray":"ember-data-3.28.13-SnapshotRecordArray-41a5f37561","ember-data-3.28.13-Snapshot":"ember-data-3.28.13-Snapshot-8da2195734","ember-data-3.28.13-StableRecordIdentifier":"ember-data-3.28.13-StableRecordIdentifier-67d7502a46","ember-data-3.28.13-MinimumAdapterInterface":"ember-data-3.28.13-MinimumAdapterInterface-5f1850dfd6","ember-data-3.28.13-MinimumSerializerInterface":"ember-data-3.28.13-MinimumSerializerInterface-d43246dc3d","ember-data-3.28.13-RecordDataStoreWrapper":"ember-data-3.28.13-RecordDataStoreWrapper-22d281635c","ember-data-3.28.13-@ember-data/adapter/error":"ember-data-3.28.13-@ember-data/adapter/error-5b196b4bdd","ember-data-3.28.13-@ember-data/adapter/rest":"ember-data-3.28.13-@ember-data/adapter/rest-b8b9325d33","ember-data-3.28.13-@ember-data/model":"ember-data-3.28.13-@ember-data/model-50f7b7c680","ember-data-3.28.13-@ember-data/store":"ember-data-3.28.13-@ember-data/store-91e3c42e96"},"module":{"ember-data-3.28.13-@ember-data/adapter":"ember-data-3.28.13-@ember-data/adapter-28757cd69c","ember-data-3.28.13-@ember-data/adapter/error":"ember-data-3.28.13-@ember-data/adapter/error-51ba0cc667","ember-data-3.28.13-@ember-data/adapter/json-api":"ember-data-3.28.13-@ember-data/adapter/json-api-cf380260be","ember-data-3.28.13-@ember-data/adapter/rest":"ember-data-3.28.13-@ember-data/adapter/rest-ddb8ef11a9","ember-data-3.28.13-@ember-data/canary-features":"ember-data-3.28.13-@ember-data/canary-features-1f5e13b831","ember-data-3.28.13-@ember-data/debug":"ember-data-3.28.13-@ember-data/debug-a78792dadb","ember-data-3.28.13-@ember-data/store":"ember-data-3.28.13-@ember-data/store-7b6c09a4db","ember-data-3.28.13-@ember-data/model":"ember-data-3.28.13-@ember-data/model-a5cce4cda2","ember-data-3.28.13-@ember-data/deprecations":"ember-data-3.28.13-@ember-data/deprecations-602dab83bb","ember-data-3.28.13-@ember-data/record-data":"ember-data-3.28.13-@ember-data/record-data-6983ea443f","ember-data-3.28.13-@ember-data/serializer":"ember-data-3.28.13-@ember-data/serializer-2e63a76738","ember-data-3.28.13-@ember-data/serializer/rest":"ember-data-3.28.13-@ember-data/serializer/rest-4f6ed21a6d","ember-data-3.28.13-@ember-data/serializer/json-api":"ember-data-3.28.13-@ember-data/serializer/json-api-b34fd57739","ember-data-3.28.13-@ember-data/serializer/json":"ember-data-3.28.13-@ember-data/serializer/json-809ddac694"},"missing":{"DataAdapter":"DataAdapter-2aae20484b","Ember.ArrayProxy":"Ember.ArrayProxy-77001d1a6f","Ember.ObjectProxy":"Ember.ObjectProxy-51e901b8e0","Ember.Service":"Ember.Service-6e7a53ed6e","EmberObject":"EmberObject-9bb68cdfb6"}}} \ No newline at end of file +{"data":{"id":"ember-data-3.28.13","type":"project-version","attributes":{"version":"3.28.13"},"relationships":{"classes":{"data":[{"id":"ember-data-3.28.13-BuildURLMixin","type":"class"},{"id":"ember-data-3.28.13-AdapterError","type":"class"},{"id":"ember-data-3.28.13-InvalidError","type":"class"},{"id":"ember-data-3.28.13-TimeoutError","type":"class"},{"id":"ember-data-3.28.13-AbortError","type":"class"},{"id":"ember-data-3.28.13-UnauthorizedError","type":"class"},{"id":"ember-data-3.28.13-ForbiddenError","type":"class"},{"id":"ember-data-3.28.13-NotFoundError","type":"class"},{"id":"ember-data-3.28.13-ConflictError","type":"class"},{"id":"ember-data-3.28.13-ServerError","type":"class"},{"id":"ember-data-3.28.13-Adapter","type":"class"},{"id":"ember-data-3.28.13-JSONAPIAdapter","type":"class"},{"id":"ember-data-3.28.13-RESTAdapter","type":"class"},{"id":"ember-data-3.28.13-InspectorDataAdapter","type":"class"},{"id":"ember-data-3.28.13-ManyArray","type":"class"},{"id":"ember-data-3.28.13-PromiseBelongsTo","type":"class"},{"id":"ember-data-3.28.13-PromiseManyArray","type":"class"},{"id":"ember-data-3.28.13-Errors","type":"class"},{"id":"ember-data-3.28.13-Model","type":"class"},{"id":"ember-data-3.28.13-RecordDataDefault","type":"class"},{"id":"ember-data-3.28.13-BooleanTransform","type":"class"},{"id":"ember-data-3.28.13-DateTransform","type":"class"},{"id":"ember-data-3.28.13-NumberTransform","type":"class"},{"id":"ember-data-3.28.13-StringTransform","type":"class"},{"id":"ember-data-3.28.13-Transform","type":"class"},{"id":"ember-data-3.28.13-EmbeddedRecordsMixin","type":"class"},{"id":"ember-data-3.28.13-Serializer","type":"class"},{"id":"ember-data-3.28.13-JSONAPISerializer","type":"class"},{"id":"ember-data-3.28.13-JSONSerializer","type":"class"},{"id":"ember-data-3.28.13-RESTSerializer","type":"class"},{"id":"ember-data-3.28.13-IdentifierCache","type":"class"},{"id":"ember-data-3.28.13-AdapterPopulatedRecordArray","type":"class"},{"id":"ember-data-3.28.13-RecordArray","type":"class"},{"id":"ember-data-3.28.13-BelongsToReference","type":"class"},{"id":"ember-data-3.28.13-HasManyReference","type":"class"},{"id":"ember-data-3.28.13-RecordReference","type":"class"},{"id":"ember-data-3.28.13-Reference","type":"class"},{"id":"ember-data-3.28.13-Store","type":"class"},{"id":"ember-data-3.28.13-FetchManager","type":"class"},{"id":"ember-data-3.28.13-PromiseArray","type":"class"},{"id":"ember-data-3.28.13-PromiseObject","type":"class"},{"id":"ember-data-3.28.13-SnapshotRecordArray","type":"class"},{"id":"ember-data-3.28.13-Snapshot","type":"class"},{"id":"ember-data-3.28.13-StableRecordIdentifier","type":"class"},{"id":"ember-data-3.28.13-MinimumAdapterInterface","type":"class"},{"id":"ember-data-3.28.13-MinimumSerializerInterface","type":"class"},{"id":"ember-data-3.28.13-RecordDataStoreWrapper","type":"class"}]},"namespaces":{"data":[]},"modules":{"data":[{"id":"ember-data-3.28.13-@ember-data/adapter","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/error","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/json-api","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/rest","type":"module"},{"id":"ember-data-3.28.13-@ember-data/canary-features","type":"module"},{"id":"ember-data-3.28.13-@ember-data/debug","type":"module"},{"id":"ember-data-3.28.13-@ember-data/store","type":"module"},{"id":"ember-data-3.28.13-@ember-data/model","type":"module"},{"id":"ember-data-3.28.13-@ember-data/deprecations","type":"module"},{"id":"ember-data-3.28.13-@ember-data/record-data","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/rest","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/json-api","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/json","type":"module"}]},"project":{"data":{"id":"ember-data","type":"project"}},"private-classes":{"data":[{"id":"ember-data-3.28.13-InspectorDataAdapter","type":"class"},{"id":"ember-data-3.28.13-PromiseBelongsTo","type":"class"},{"id":"ember-data-3.28.13-FetchManager","type":"class"}]},"public-classes":{"data":[{"id":"ember-data-3.28.13-BuildURLMixin","type":"class"},{"id":"ember-data-3.28.13-AdapterError","type":"class"},{"id":"ember-data-3.28.13-InvalidError","type":"class"},{"id":"ember-data-3.28.13-TimeoutError","type":"class"},{"id":"ember-data-3.28.13-AbortError","type":"class"},{"id":"ember-data-3.28.13-UnauthorizedError","type":"class"},{"id":"ember-data-3.28.13-ForbiddenError","type":"class"},{"id":"ember-data-3.28.13-NotFoundError","type":"class"},{"id":"ember-data-3.28.13-ConflictError","type":"class"},{"id":"ember-data-3.28.13-ServerError","type":"class"},{"id":"ember-data-3.28.13-Adapter","type":"class"},{"id":"ember-data-3.28.13-JSONAPIAdapter","type":"class"},{"id":"ember-data-3.28.13-RESTAdapter","type":"class"},{"id":"ember-data-3.28.13-ManyArray","type":"class"},{"id":"ember-data-3.28.13-PromiseManyArray","type":"class"},{"id":"ember-data-3.28.13-Errors","type":"class"},{"id":"ember-data-3.28.13-Model","type":"class"},{"id":"ember-data-3.28.13-RecordDataDefault","type":"class"},{"id":"ember-data-3.28.13-BooleanTransform","type":"class"},{"id":"ember-data-3.28.13-DateTransform","type":"class"},{"id":"ember-data-3.28.13-NumberTransform","type":"class"},{"id":"ember-data-3.28.13-StringTransform","type":"class"},{"id":"ember-data-3.28.13-Transform","type":"class"},{"id":"ember-data-3.28.13-EmbeddedRecordsMixin","type":"class"},{"id":"ember-data-3.28.13-Serializer","type":"class"},{"id":"ember-data-3.28.13-JSONAPISerializer","type":"class"},{"id":"ember-data-3.28.13-JSONSerializer","type":"class"},{"id":"ember-data-3.28.13-RESTSerializer","type":"class"},{"id":"ember-data-3.28.13-IdentifierCache","type":"class"},{"id":"ember-data-3.28.13-AdapterPopulatedRecordArray","type":"class"},{"id":"ember-data-3.28.13-RecordArray","type":"class"},{"id":"ember-data-3.28.13-BelongsToReference","type":"class"},{"id":"ember-data-3.28.13-HasManyReference","type":"class"},{"id":"ember-data-3.28.13-RecordReference","type":"class"},{"id":"ember-data-3.28.13-Reference","type":"class"},{"id":"ember-data-3.28.13-Store","type":"class"},{"id":"ember-data-3.28.13-PromiseArray","type":"class"},{"id":"ember-data-3.28.13-PromiseObject","type":"class"},{"id":"ember-data-3.28.13-SnapshotRecordArray","type":"class"},{"id":"ember-data-3.28.13-Snapshot","type":"class"},{"id":"ember-data-3.28.13-StableRecordIdentifier","type":"class"},{"id":"ember-data-3.28.13-MinimumAdapterInterface","type":"class"},{"id":"ember-data-3.28.13-MinimumSerializerInterface","type":"class"},{"id":"ember-data-3.28.13-RecordDataStoreWrapper","type":"class"}]},"private-namespaces":{"data":[]},"public-namespaces":{"data":[]},"private-modules":{"data":[]},"public-modules":{"data":[{"id":"ember-data-3.28.13-@ember-data/adapter","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/error","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/json-api","type":"module"},{"id":"ember-data-3.28.13-@ember-data/adapter/rest","type":"module"},{"id":"ember-data-3.28.13-@ember-data/canary-features","type":"module"},{"id":"ember-data-3.28.13-@ember-data/debug","type":"module"},{"id":"ember-data-3.28.13-@ember-data/store","type":"module"},{"id":"ember-data-3.28.13-@ember-data/model","type":"module"},{"id":"ember-data-3.28.13-@ember-data/deprecations","type":"module"},{"id":"ember-data-3.28.13-@ember-data/record-data","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/rest","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/json-api","type":"module"},{"id":"ember-data-3.28.13-@ember-data/serializer/json","type":"module"}]}}},"meta":{"class":{"ember-data-3.28.13-BuildURLMixin":"ember-data-3.28.13-BuildURLMixin-29a90f7ddd","ember-data-3.28.13-AdapterError":"ember-data-3.28.13-AdapterError-c031975b42","ember-data-3.28.13-InvalidError":"ember-data-3.28.13-InvalidError-015c442b59","ember-data-3.28.13-TimeoutError":"ember-data-3.28.13-TimeoutError-1cef024b23","ember-data-3.28.13-AbortError":"ember-data-3.28.13-AbortError-f2235db04c","ember-data-3.28.13-UnauthorizedError":"ember-data-3.28.13-UnauthorizedError-83658f3060","ember-data-3.28.13-ForbiddenError":"ember-data-3.28.13-ForbiddenError-956cdba782","ember-data-3.28.13-NotFoundError":"ember-data-3.28.13-NotFoundError-743ee0c647","ember-data-3.28.13-ConflictError":"ember-data-3.28.13-ConflictError-98876f4bf7","ember-data-3.28.13-ServerError":"ember-data-3.28.13-ServerError-e35abd623a","ember-data-3.28.13-Adapter":"ember-data-3.28.13-Adapter-17bacb1a7f","ember-data-3.28.13-JSONAPIAdapter":"ember-data-3.28.13-JSONAPIAdapter-1d32cc56aa","ember-data-3.28.13-RESTAdapter":"ember-data-3.28.13-RESTAdapter-b5df0eb287","ember-data-3.28.13-InspectorDataAdapter":"ember-data-3.28.13-InspectorDataAdapter-85b38ef2eb","ember-data-3.28.13-ManyArray":"ember-data-3.28.13-ManyArray-ced4bd0bfe","ember-data-3.28.13-PromiseBelongsTo":"ember-data-3.28.13-PromiseBelongsTo-104303fe9e","ember-data-3.28.13-PromiseManyArray":"ember-data-3.28.13-PromiseManyArray-07460523fc","ember-data-3.28.13-Errors":"ember-data-3.28.13-Errors-9bc753c95a","ember-data-3.28.13-Model":"ember-data-3.28.13-Model-484bf6ed29","ember-data-3.28.13-RecordDataDefault":"ember-data-3.28.13-RecordDataDefault-c301edf248","ember-data-3.28.13-BooleanTransform":"ember-data-3.28.13-BooleanTransform-2d70931902","ember-data-3.28.13-DateTransform":"ember-data-3.28.13-DateTransform-fc695f3da6","ember-data-3.28.13-NumberTransform":"ember-data-3.28.13-NumberTransform-6cc15c870c","ember-data-3.28.13-StringTransform":"ember-data-3.28.13-StringTransform-e22b28a886","ember-data-3.28.13-Transform":"ember-data-3.28.13-Transform-5f90a14566","ember-data-3.28.13-EmbeddedRecordsMixin":"ember-data-3.28.13-EmbeddedRecordsMixin-0ab259b966","ember-data-3.28.13-Serializer":"ember-data-3.28.13-Serializer-f215e04bef","ember-data-3.28.13-JSONAPISerializer":"ember-data-3.28.13-JSONAPISerializer-bd4f2cba28","ember-data-3.28.13-JSONSerializer":"ember-data-3.28.13-JSONSerializer-8566db9bca","ember-data-3.28.13-RESTSerializer":"ember-data-3.28.13-RESTSerializer-e01f8ddf48","ember-data-3.28.13-IdentifierCache":"ember-data-3.28.13-IdentifierCache-319a57680a","ember-data-3.28.13-AdapterPopulatedRecordArray":"ember-data-3.28.13-AdapterPopulatedRecordArray-306cc2f9c0","ember-data-3.28.13-RecordArray":"ember-data-3.28.13-RecordArray-3cdc3a8f26","ember-data-3.28.13-BelongsToReference":"ember-data-3.28.13-BelongsToReference-c27337a2f0","ember-data-3.28.13-HasManyReference":"ember-data-3.28.13-HasManyReference-187134d9f4","ember-data-3.28.13-RecordReference":"ember-data-3.28.13-RecordReference-6c446acafd","ember-data-3.28.13-Reference":"ember-data-3.28.13-Reference-125917c3ed","ember-data-3.28.13-Store":"ember-data-3.28.13-Store-cadfb8849f","ember-data-3.28.13-FetchManager":"ember-data-3.28.13-FetchManager-8996d4eb65","ember-data-3.28.13-PromiseArray":"ember-data-3.28.13-PromiseArray-a081c07520","ember-data-3.28.13-PromiseObject":"ember-data-3.28.13-PromiseObject-e303008768","ember-data-3.28.13-SnapshotRecordArray":"ember-data-3.28.13-SnapshotRecordArray-d7fdb43022","ember-data-3.28.13-Snapshot":"ember-data-3.28.13-Snapshot-a430655fd4","ember-data-3.28.13-StableRecordIdentifier":"ember-data-3.28.13-StableRecordIdentifier-67d7502a46","ember-data-3.28.13-MinimumAdapterInterface":"ember-data-3.28.13-MinimumAdapterInterface-e647b24afc","ember-data-3.28.13-MinimumSerializerInterface":"ember-data-3.28.13-MinimumSerializerInterface-31366d5385","ember-data-3.28.13-RecordDataStoreWrapper":"ember-data-3.28.13-RecordDataStoreWrapper-22d281635c","ember-data-3.28.13-@ember-data/adapter/error":"ember-data-3.28.13-@ember-data/adapter/error-e2bd41804e","ember-data-3.28.13-@ember-data/adapter/rest":"ember-data-3.28.13-@ember-data/adapter/rest-b8b9325d33","ember-data-3.28.13-@ember-data/model":"ember-data-3.28.13-@ember-data/model-52da829c82","ember-data-3.28.13-@ember-data/store":"ember-data-3.28.13-@ember-data/store-9648856af0"},"module":{"ember-data-3.28.13-@ember-data/adapter":"ember-data-3.28.13-@ember-data/adapter-44a8d9698e","ember-data-3.28.13-@ember-data/adapter/error":"ember-data-3.28.13-@ember-data/adapter/error-80a5cf85b4","ember-data-3.28.13-@ember-data/adapter/json-api":"ember-data-3.28.13-@ember-data/adapter/json-api-8cc1851d56","ember-data-3.28.13-@ember-data/adapter/rest":"ember-data-3.28.13-@ember-data/adapter/rest-1271a8f380","ember-data-3.28.13-@ember-data/canary-features":"ember-data-3.28.13-@ember-data/canary-features-26e7210afe","ember-data-3.28.13-@ember-data/debug":"ember-data-3.28.13-@ember-data/debug-68bca8ad7e","ember-data-3.28.13-@ember-data/store":"ember-data-3.28.13-@ember-data/store-173b52ab7d","ember-data-3.28.13-@ember-data/model":"ember-data-3.28.13-@ember-data/model-0a37a6db52","ember-data-3.28.13-@ember-data/deprecations":"ember-data-3.28.13-@ember-data/deprecations-602dab83bb","ember-data-3.28.13-@ember-data/record-data":"ember-data-3.28.13-@ember-data/record-data-6983ea443f","ember-data-3.28.13-@ember-data/serializer":"ember-data-3.28.13-@ember-data/serializer-fdd495c39c","ember-data-3.28.13-@ember-data/serializer/rest":"ember-data-3.28.13-@ember-data/serializer/rest-6dcd17b48d","ember-data-3.28.13-@ember-data/serializer/json-api":"ember-data-3.28.13-@ember-data/serializer/json-api-b473fed6b9","ember-data-3.28.13-@ember-data/serializer/json":"ember-data-3.28.13-@ember-data/serializer/json-a8fe5001d6"},"missing":{"DataAdapter":"DataAdapter-2aae20484b","Ember.ArrayProxy":"Ember.ArrayProxy-77001d1a6f","Ember.ObjectProxy":"Ember.ObjectProxy-51e901b8e0","Ember.Service":"Ember.Service-6e7a53ed6e","EmberObject":"EmberObject-9bb68cdfb6"}}} \ No newline at end of file