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:
| State | Type |
|---|---|
<name> | { results, total, page, pages, limit, offset } |
<name>Loading | boolean |
<name>Error | ApiError | null |
| Getter | Returns |
|---|---|
get<Name> | state slice |
is<Name>Loading | boolean |
get<Name>Error | error or null |
| Action | Signature |
|---|---|
fetch<Name> | (type, objectId, params?) => Promise<Array> |
clear<Name> | () => void |
For the exact mapping see createSubResourcePlugin.
Extra action
| Action | Description |
|---|---|
clearRelations() | Calls clearContracts(), clearUses(), clearUsed() in one go. |