API Docs for: 0.2.1
Show:

StoreService Class

Module: store
Parent Module: ember-jsonapi-resources

Service for a JSON API endpoint a facade to your resource adapter

Methods

_service

(
  • type
  • options
)
private

Lookup the injected service for a resource, pluralize type arg.

Parameters:

  • type String
    • the entity or resource name will be pluralized unless a {singleton: true} option is passed
  • options Object

    (object)

all

(
  • type
)
Ember.Array

Access to the cached object

Parameters:

  • type String

    the entity or resource name will be pluralized

Returns:

Ember.Array:

createRelationship

(
  • type
  • resource
  • relationship
  • id
)
Promise

Create (add) a relationship for to-many relation, sends a POST request.

See: http://jsonapi.org/format/#crud-updating-to-many-relationships

Adds a relation using a payload with a resource identifier object:

{
  "data": [
    { "type": "comments", "id": "12" }
  ]
}

Parameters:

  • type String

    the entity or resource name will be pluralized

  • resource Resource

    instance, has URLs via it's relationships property

  • relationship String

    name (plural) to find the url from the resource instance

  • id String

    of the related resource

Returns:

Promise:

createResource

(
  • type
  • resource
)
Promise

Create a new resource, sends a POST request

Parameters:

  • type String

    the entity or resource name will be pluralized

  • resource Resource

    instance to serialize

Returns:

Promise:

deleteRelationship

(
  • type
  • resource
  • relationship
  • id
)
Promise

Deletes a relationship for to-many relation, sends a DELETE request.

See: http://jsonapi.org/format/#crud-updating-to-many-relationships

Remove using a payload with the resource identifier object:

For to-many:

{
  "data": [
    { "type": "comments", "id": "1" }
  ]
}

Parameters:

  • type String

    the entity or resource name will be pluralized

  • resource Resource

    instance, has URLs via it's relationships property

  • relationship String

    name (plural) to find the url from the resource instance

  • id String

    of the related resource

Returns:

Promise:

deleteResource

(
  • type
  • resource
)
Promise

Delete an existing resource, sends a DELETE request

Parameters:

  • type String

    the entity or resource name will be pluralized

  • resource String | Resource

    name (plural) or instance with self link

Returns:

Promise:

find

(
  • type
  • options
)
Promise

Find resource(s) using an id or a using a query {id: '', query: {}}

Parameters:

  • type String

    the entity or resource name will be pluralized unless a {singleton: true} option is passed

  • options Object | String

    object or (string) id

Returns:

Promise:

initialize

()

Provided by the initializers module.

Defined in addon/initializers/store.js:8

Initializer for the store service, injects into the route and controller

patchRelationship

(
  • type
  • resource
  • relationship
)
Promise

Patch a relationship, either adds or removes everyting, sends a PATCH request.

See: http://jsonapi.org/format/#crud-updating-to-one-relationships

For to-one relation:

  • Remove (delete) with payload: { "data": null }
  • Create/Update with payload:
    {
      "data": { "type": "comments", "id": "1" }
    }
    

For to-many relation:

  • Remove (delete) all with payload: { "data": [] }
  • Replace all with payload:
    {
      "data": [
        { "type": "comments", "id": "1" },
        { "type": "comments", "id": "2" }
      ]
    }
    

Parameters:

  • type String

    the entity or resource name will be pluralized

  • resource Resource

    instance, has URLs via it's relationships property

  • relationship String

    name (plural) to find the url from the resource instance

Returns:

Promise:

updateResource

(
  • type
  • resource
  • includeRelationships
)
Promise

Patch an existing resource, sends a PATCH request.

Parameters:

  • type String

    the entity or resource name will be pluralized

  • resource Resource

    instance to serialize the changed attributes

  • includeRelationships Array

    (optional) list of {String} relationships to opt-into an update

Returns:

Promise: