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:
-
type
String- 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
-
options
Object(object)
all
-
type
Access to the cached object
Parameters:
-
type
Stringthe 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:
-
type
Stringthe entity or resource name will be pluralized
-
resource
Resourceinstance, has URLs via it's relationships property
-
relationship
Stringname (plural) to find the url from the resource instance
-
id
Stringof the related resource
Returns:
createResource
-
type
-
resource
Create a new resource, sends a POST request
Parameters:
-
type
Stringthe entity or resource name will be pluralized
-
resource
Resourceinstance 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:
-
type
Stringthe entity or resource name will be pluralized
-
resource
Resourceinstance, has URLs via it's relationships property
-
relationship
Stringname (plural) to find the url from the resource instance
-
id
Stringof the related resource
Returns:
deleteResource
-
type
-
resource
Delete an existing resource, sends a DELETE request
Parameters:
-
type
Stringthe entity or resource name will be pluralized
-
resource
String | 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:
-
type
Stringthe entity or resource name will be pluralized unless a
{singleton: true}
option is passed -
options
Object | 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:
-
type
Stringthe entity or resource name will be pluralized
-
resource
Resourceinstance, has URLs via it's relationships property
-
relationship
Stringname (plural) to find the url from the resource instance
Returns:
updateResource
-
type
-
resource
-
includeRelationships
Patch an existing resource, sends a PATCH request.
Parameters:
-
type
Stringthe entity or resource name will be pluralized
-
resource
Resourceinstance to serialize the changed attributes
-
includeRelationships
Array(optional) list of {String} relationships to opt-into an update