Skip to content

cozy-client / HasManyTriggers

Class: HasManyTriggers

Association used for konnectors to retrieve all their related triggers.

Hierarchy

Constructors

constructor

new HasManyTriggers(target, name, doctype, options)

Parameters

Name Type Description
target any Original object containing raw data
name string Attribute under which the association is stored
doctype string Doctype of the documents managed by the association
options Object Options passed from the client
options.dispatch Function Store’s dispatch, comes from the client
options.get Function Get a document from the store
options.mutate Function Execute client mutate
options.query Function Execute client query
options.save Function Execute client save

Inherited from

HasMany.constructor

Defined in

packages/cozy-client/src/associations/Association.js:87

Properties

dispatch

dispatch: Function

Dispatch an action on the store.

Inherited from

HasMany.dispatch

Defined in

packages/cozy-client/src/associations/Association.js:144


doctype

doctype: string

Doctype of the relationship

example ‘io.cozy.authors’

Inherited from

HasMany.doctype

Defined in

packages/cozy-client/src/associations/Association.js:109


get

get: Function

Returns the document from the store

Inherited from

HasMany.get

Defined in

packages/cozy-client/src/associations/Association.js:116


mutate

mutate: Function

Performs a mutation on the relationship.

function

Inherited from

HasMany.mutate

Defined in

packages/cozy-client/src/associations/Association.js:131


name

name: string

The name of the relationship.

example ‘author’

Inherited from

HasMany.name

Defined in

packages/cozy-client/src/associations/Association.js:101


query

query: Function

Performs a query to retrieve relationship documents.

param

function

Inherited from

HasMany.query

Defined in

packages/cozy-client/src/associations/Association.js:124


save

save: Function

Saves the relationship in store.

Inherited from

HasMany.save

Defined in

packages/cozy-client/src/associations/Association.js:138


target

target: any

The original document declaring the relationship

Inherited from

HasMany.target

Defined in

packages/cozy-client/src/associations/Association.js:94

Accessors

count

get count(): number

Returns the total number of documents in the relationship. Does not handle documents absent from the store. If you want to do that, you can use .data.length.

Returns

number

  • Total number of documents in the relationships

Inherited from

HasMany.count

Defined in

packages/cozy-client/src/associations/HasMany.js:93


data

get data(): any

Returns

any

Overrides

HasMany.data

Defined in

packages/cozy-client/src/associations/HasManyTriggers.js:12


hasMore

get hasMore(): any

Returns

any

Inherited from

HasMany.hasMore

Defined in

packages/cozy-client/src/associations/HasMany.js:82


raw

get raw(): any

Returns

any

Inherited from

HasMany.raw

Defined in

packages/cozy-client/src/associations/HasMany.js:69

Methods

add

add(docsArg): CozyClientDocument

Add the relationships to the target document

Parameters

Name Type Description
docsArg CozyClientDocument[] Documents to add as relationships

Returns

CozyClientDocument

The saved target document

Inherited from

HasMany.add

Defined in

packages/cozy-client/src/associations/HasMany.js:124


addById

addById(idsArg): any

Add a referenced document by id. You need to call save() in order to synchronize your document with the store.

todo We shouldn’t create the array of relationship manually since it’ll not be present in the store as well. We certainly should use something like updateRelationship

Parameters

Name Type
idsArg any

Returns

any

Inherited from

HasMany.addById

Defined in

packages/cozy-client/src/associations/HasMany.js:174


addTargetRelationships

addTargetRelationships(idsArg): void

Update target document with relationships

Parameters

Name Type Description
idsArg string[] The ids to add as a relationship

Returns

void

Inherited from

HasMany.addTargetRelationships

Defined in

packages/cozy-client/src/associations/HasMany.js:147


containsById

containsById(id): boolean

Parameters

Name Type
id any

Returns

boolean

Inherited from

HasMany.containsById

Defined in

packages/cozy-client/src/associations/HasMany.js:108


dehydrate

dehydrate(doc): any

Parameters

Name Type
doc any

Returns

any

Inherited from

HasMany.dehydrate

Defined in

packages/cozy-client/src/associations/HasMany.js:256


exists

exists(document): boolean

Parameters

Name Type
document any

Returns

boolean

Inherited from

HasMany.exists

Defined in

packages/cozy-client/src/associations/HasMany.js:104


existsById

existsById(id): boolean

Parameters

Name Type
id any

Returns

boolean

Inherited from

HasMany.existsById

Defined in

packages/cozy-client/src/associations/HasMany.js:114


fetchMore

fetchMore(): void

Returns

void

Inherited from

HasMany.fetchMore

Defined in

packages/cozy-client/src/associations/HasMany.js:100


getRelationship

getRelationship(): any

Returns

any

Inherited from

HasMany.getRelationship

Defined in

packages/cozy-client/src/associations/HasMany.js:207


remove

remove(docsArg): CozyClientDocument

Remove the relationships from the target document

Parameters

Name Type Description
docsArg CozyClientDocument[] Documents to remove as relationships

Returns

CozyClientDocument

The saved target document

Inherited from

HasMany.remove

Defined in

packages/cozy-client/src/associations/HasMany.js:136


removeById

removeById(idsArg): any

Parameters

Name Type
idsArg any

Returns

any

Inherited from

HasMany.removeById

Defined in

packages/cozy-client/src/associations/HasMany.js:193


removeTargetRelationships

removeTargetRelationships(idsArg): void

Remove relationships from target document

Parameters

Name Type Description
idsArg string[] The ids to remove from the target relationships

Returns

void

Inherited from

HasMany.removeTargetRelationships

Defined in

packages/cozy-client/src/associations/HasMany.js:184


updateMetaCount

updateMetaCount(): void

Returns

void

Inherited from

HasMany.updateMetaCount

Defined in

packages/cozy-client/src/associations/HasMany.js:198


updateRelationship

updateRelationship(target, updateFn): any

Parameters

Name Type
target any
updateFn any

Returns

any

Inherited from

HasMany.updateRelationship

Defined in

packages/cozy-client/src/associations/HasMany.js:228


updateRelationshipData

updateRelationshipData(getUpdatedRelationshipData): (dispatch: any, getState: any) => void

Parameters

Name Type
getUpdatedRelationshipData any

Returns

fn

▸ (dispatch, getState): void

Parameters

Name Type
dispatch any
getState any

Returns

void

Inherited from

HasMany.updateRelationshipData

Defined in

packages/cozy-client/src/associations/HasMany.js:232


updateTargetRelationship

updateTargetRelationship(store, updateFn): void

Parameters

Name Type
store any
updateFn any

Returns

void

Inherited from

HasMany.updateTargetRelationship

Defined in

packages/cozy-client/src/associations/HasMany.js:221


getHasManyItem

Static getHasManyItem(doc, relName, relItemId): any

Parameters

Name Type
doc any
relName string
relItemId string

Returns

any

Inherited from

HasMany.getHasManyItem

Defined in

packages/cozy-client/src/associations/HasMany.js:289


getHasManyItems

Static getHasManyItems(doc, relName): any

Parameters

Name Type
doc any
relName any

Returns

any

Inherited from

HasMany.getHasManyItems

Defined in

packages/cozy-client/src/associations/HasMany.js:298


query

Static query(doc, client): QueryDefinition

In this association the query is special, we need to fetch all the triggers having for the ‘konnector’ worker, and then filter them based on their message.konnector attribute

Parameters

Name Type
doc any
client any

Returns

QueryDefinition

Overrides

HasMany.query

Defined in

packages/cozy-client/src/associations/HasManyTriggers.js:21


removeHasManyItem

Static removeHasManyItem(doc, relName, relItemId): any

Parameters

Name Type
doc any
relName string
relItemId string

Returns

any

Inherited from

HasMany.removeHasManyItem

Defined in

packages/cozy-client/src/associations/HasMany.js:336


setHasManyItem

Static setHasManyItem(doc, relName, relItemId, relItemAttrs): any

Parameters

Name Type
doc any
relName string
relItemId string
relItemAttrs any

Returns

any

Inherited from

HasMany.setHasManyItem

Defined in

packages/cozy-client/src/associations/HasMany.js:310


updateHasManyItem

Static updateHasManyItem(doc, relName, relItemId, updater): any

Parameters

Name Type
doc any
relName string
relItemId string
updater Function

Returns

any

Inherited from

HasMany.updateHasManyItem

Defined in

packages/cozy-client/src/associations/HasMany.js:360


updateRelationship

Static updateRelationship(doc, relName, updateFn): any

Parameters

Name Type
doc any
relName any
updateFn any

Returns

any

Inherited from

HasMany.updateRelationship

Defined in

packages/cozy-client/src/associations/HasMany.js:371