Skip to main content

relationsPlugin

Adds three OpenRegister relation sub-resources to the object store in one call:

  • contracts — contractual relations between objects (endpoint /contracts).
  • uses — outgoing references this object makes to others (endpoint /uses).
  • used — incoming references — which other objects reference this one (endpoint /used).

Each is generated by createSubResourcePlugin and gets its own state, getters, and actions.

Usage

import { createObjectStore, relationsPlugin } from '@conduction/nextcloud-vue'

const useMyStore = createObjectStore('myapp', {
plugins: [relationsPlugin()],
})

const store = useMyStore()

await store.fetchContracts('case', caseId)
await store.fetchUses('case', caseId)
await store.fetchUsed('case', caseId)

store.clearRelations() // clears all three sub-resources

Generated surface

For each of contracts, uses, used the plugin adds:

StateType
<name>{ results, total, page, pages, limit, offset }
<name>Loadingboolean
<name>ErrorApiError | null
GetterReturns
get<Name>state slice
is<Name>Loadingboolean
get<Name>Errorerror or null
ActionSignature
fetch<Name>(type, objectId, params?) => Promise<Array>
clear<Name>() => void

For the exact mapping see createSubResourcePlugin.

Extra action

ActionDescription
clearRelations()Calls clearContracts(), clearUses(), clearUsed() in one go.