Namespace: actions

pinia-jsonapi.createJsonapiStore.actions

Pinia actions, used via this.$store.dispatch, e.g.: this.$store.dispatch('jv/get', <args>)

args can be either a string or an object representing the item(s) required, or it can be an array of string/object and an optional axios config object.

Source:

Methods

(static) addRecords(records)

Add record(s) to the store, according to mergeRecords config option

Parameters:
Name Type Description
records object

The record(s) to be added

Source:

(static) clearRecords(records)

Delete all records from the store (of a given type) other than those included in a given record

Parameters:
Name Type Description
records object

A record with type set.

Source:

(async, static) create()

Source:

(async, static) delete(args) → {object}

Delete an item from the API

Parameters:
Name Type Description
args string | object | array

See module:pinia-jsonapi.createJsonapiStore.actions for a summary of args

string

A URL path to an item - e.g. endpoint/1

object

A restructured object - e.g. { _jv: { type: "endpoint", id: "1" } }

array

A 2-element array, consisting of a string/object and an optional axios config object

Source:
Returns:

Restructured representation of the deleted item

Type
object

(static) deleteRecord(record)

Delete a record from the store.

Parameters:
Name Type Description
record string | object

The record to be deleted

Source:

(async, static) deleteRelated(args) → {object}

DELETE an object's relationships via its relationships URL

Parameters:
Name Type Description
args object

A restructured object, specifying relationship(s) - e.g. { _jv: { type: "endpoint", id: "1", relationships: {...} } }

Source:
Returns:

Restructured representation of the 'parent' item

Type
object

(async, static) fetch()

Source:

(async, static) get(args) → {object}

Get items from the API

Parameters:
Name Type Description
args string | object | array

See module:pinia-jsonapi.createJsonapiStore.actions for a summary of args

string

A URL path to an item - e.g. endpoint/1

object

A restructured object - e.g. { _jv: { type: "endpoint", id: "1" } }

array

A 2-element array, consisting of a string/object and an optional axios config object

Source:
Returns:

Restructured representation of the requested item(s)

Type
object

(async, static) getRelated(args) → {object}

Get related items from the API

Parameters:
Name Type Description
args string | object | array

See module:pinia-jsonapi.createJsonapiStore.actions for a summary of args

string

A URL path to an item - e.g. endpoint/1

object

A restructured object - e.g. { _jv: { type: "endpoint", id: "1" } }

array

A 2-element array, consisting of a string/object and an optional axios config object

Source:
Returns:

Restructured representation of the requested item(s)

Type
object

(static) mergeRecords(records)

Merge (or add) records to the store

Parameters:
Name Type Description
records object

The record(s) to be merged

Source:

(async, static) patch(args) → {object}

Patch an item in the API

Parameters:
Name Type Description
args object | array

See module:pinia-jsonapi.createJsonapiStore.actions for a summary of args

object

A restructured object - e.g. { _jv: { type: "endpoint", id: "1" } }

array

A 2-element array, consisting of a string/object and an optional axios config object

Source:
Returns:

Restructured representation of the patched item

Type
object

(async, static) patchRelated(args) → {object}

PATCH an object's relationships via its relationships URL

Parameters:
Name Type Description
args object

A restructured object, specifying relationship(s) - e.g. { _jv: { type: "endpoint", id: "1", relationships: {...} } }

Source:
Returns:

Restructured representation of the 'parent' item

Type
object

(async, static) post(args) → {object}

Post an item to the API

Parameters:
Name Type Description
args object | array

See module:pinia-jsonapi.createJsonapiStore.actions for a summary of args

object

A restructured object - e.g. { _jv: { type: "endpoint", id: "1" } }

array

A 2-element array, consisting of a string/object and an optional axios config object

Source:
Returns:

Restructured representation of the posted item

Type
object

(async, static) postRelated(args) → {object}

POST to an object's relationships via its relationships URL

Parameters:
Name Type Description
args object

A restructured object, specifying relationship(s) - e.g. { _jv: { type: "endpoint", id: "1", relationships: {...} } }

Source:
Returns:

Restructured representation of the 'parent' item

Type
object

(static) replaceRecords(records)

Replace (or add) record(s) to the store

Parameters:
Name Type Description
records object

The record(s) to be replaced

Source:

(async, static) search(args) → {object}

Get items from the API without updating the Pinia store

Parameters:
Name Type Description
args string | object | array

See module:pinia-jsonapi.createJsonapiStore.actions for a summary of args

string

A URL path to an item - e.g. endpoint/1

object

A restructured object - e.g. { _jv: { type: "endpoint", id: "1" } }

array

A 2-element array, consisting of a string/object and an optional axios config object

Source:
See:
Returns:

Restructured representation of the posted item

Type
object

(async, static) update()

Source:

(async, static) writeRelated(args, args) → {object}

Internal method to 'write' related items from the API. This method is wrapped by (delete|patch|post)Related actions, and is not available directly as an action.

Parameters:
Name Type Description
args object

A restructured object, specifying relationship(s) - e.g. { _jv: { type: "endpoint", id: "1", relationships: {...} } }

args object

A restructured object, specifying relationship(s) - e.g. { _jv: { type: "endpoint", id: "1", relationships: {...} } }

Source:
Returns:

Restructured representation of the 'parent' item

Type
object