API Docs for: 0.2.1
Show:

ResourceOperationsMixin Class

Mixin to provide interations between a Resource instance and service/adapter.

Methods

createRelationship

(
  • relationship
  • id
  • errorCallback
)
Promise

Create a relationship for a to-many relation, calls service to persist.

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

Calling this.createRelationship will call the service to persist the changes, via it's createRelationship method. Since the default catch for this method is to rollback the relationships, an optional errorCallback function can be used to handle the error response.

Parameters:

  • relationship String

    name (plural) to find the url

  • id String

    of the related resource

  • errorCallback Function

    function (error) {}

Returns:

Promise:

createResource

() Promise

Create a new resource, calls service to persist new model

Calling this.createResource will call the service to persist the new model, via it's createResource method.

Returns:

Promise:

deleteRelationship

(
  • relationship
  • id
  • errorCallback
)
Promise

Deletes a relationship for to-many relation, calls service to persist.

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

Calling this.deleteRelationship will call the service to persist the changes, via it's deleteRelationship method. Since the default catch for this method is to rollback the relationships, an optional errorCallback function can be used to handle the error response.

Parameters:

  • relationship String

    name (plural) to find the url

  • id String

    of the related resource

  • errorCallback Function

    function (error) {}

Returns:

Promise:

deleteResource

() Promise

Delete a persistend resource, calls service to DELETE via API request

Calling this.deleteResource will call the service to remove the destroy, via it's deleteResource method.

Returns:

Promise:

updateRelationship

(
  • relationship
  • ids
  • errorCallback
)
Promise

Update a relationship, works with both to-many and to-one. Primarily use with to-one and to-many is for a full replacement only.

For a to-one relationship, add, replace or remove, and persist the change using the service. With an id the relation will be added or changed, with null a relationship will be removed.

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

For to-many relationships the backend will need to support editing as a set, full replacement (most often that may be disabled). The list of all related resource identifiers will be sent to the server as a replace operation.

Update a relationship by adding or removing using a list, id, or null. When adding an id for a to-many relationship send one or more ids, include the existing ids as well. When removing from a to-many relationship pass the ids that should remain, missing ids will be removed, or remove all with an empty array.

Calling this.updateRelationship will call the service to persist the changes, via it's patchRelationship method. Since the default catch for this method is to rollback the relationships, an optional errorCallback function can be used to handle the error response.

Parameters:

  • relationship String

    name

  • ids Array | String | Null

    can be only one id or null to remove

  • errorCallback Function

    function (error) {}

Returns:

Promise:

updateResource

() Promise

Update a persistend resource, calls service to persist changes

Calling this.updateResource will call the service to persist the changes, via it's updateResource method.

Returns:

Promise:

Properties

service

Object

The service object for the entity (adapter with cache and serializer)