ResourceOperationsMixin Class
Mixin to provide interations between a Resource instance and service/adapter.
Item Index
Methods
Properties
Methods
createRelationship
-
relationship -
id -
errorCallback
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:
-
relationshipStringname (plural) to find the url
-
idStringof the related resource
-
errorCallbackFunctionfunction (error) {}
Returns:
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:
deleteRelationship
-
relationship -
id -
errorCallback
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:
-
relationshipStringname (plural) to find the url
-
idStringof the related resource
-
errorCallbackFunctionfunction (error) {}
Returns:
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:
updateRelationship
-
relationship -
ids -
errorCallback
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:
-
relationshipStringname
-
idsArray | String | Nullcan be only one id or null to remove
-
errorCallbackFunctionfunction (error) {}
Returns:
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:
Properties
service
Object
The service object for the entity (adapter with cache and serializer)
