StoreService Class
Service for a JSON API endpoint a facade to your resource adapter
Item Index
Methods
_service
-
type -
options
Lookup the injected service for a resource, pluralize type arg.
Parameters:
-
typeString- the entity or resource name will be pluralized unless a
{singleton: true}option is passed
- the entity or resource name will be pluralized unless a
-
optionsObject(object)
all
-
type
Access to the cached object
Parameters:
-
typeStringthe entity or resource name will be pluralized
Returns:
createRelationship
-
type -
resource -
relationship -
id
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:
-
typeStringthe entity or resource name will be pluralized
-
resourceResourceinstance, has URLs via it's relationships property
-
relationshipStringname (plural) to find the url from the resource instance
-
idStringof the related resource
Returns:
createResource
-
type -
resource
Create a new resource, sends a POST request
Parameters:
-
typeStringthe entity or resource name will be pluralized
-
resourceResourceinstance to serialize
Returns:
deleteRelationship
-
type -
resource -
relationship -
id
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:
-
typeStringthe entity or resource name will be pluralized
-
resourceResourceinstance, has URLs via it's relationships property
-
relationshipStringname (plural) to find the url from the resource instance
-
idStringof the related resource
Returns:
deleteResource
-
type -
resource
Delete an existing resource, sends a DELETE request
Parameters:
-
typeStringthe entity or resource name will be pluralized
-
resourceString | Resourcename (plural) or instance with self link
Returns:
find
-
type -
options
Find resource(s) using an id or a using a query {id: '', query: {}}
Parameters:
-
typeStringthe entity or resource name will be pluralized unless a
{singleton: true}option is passed -
optionsObject | Stringobject or (string) id
Returns:
initialize
()
Initializer for the store service, injects into the route and controller
patchRelationship
-
type -
resource -
relationship
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:
-
typeStringthe entity or resource name will be pluralized
-
resourceResourceinstance, has URLs via it's relationships property
-
relationshipStringname (plural) to find the url from the resource instance
Returns:
updateResource
-
type -
resource -
includeRelationships
Patch an existing resource, sends a PATCH request.
Parameters:
-
typeStringthe entity or resource name will be pluralized
-
resourceResourceinstance to serialize the changed attributes
-
includeRelationshipsArray(optional) list of {String} relationships to opt-into an update
