Files
dashlibstorage/API.entitycontact.md
2026-09-24 23:26:25 +02:00

122 lines
3.0 KiB
Markdown

# entitycontact
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
## `entitycontact.create`
*Source: `src/store/entitycontact/create.js`*
Creates a new contact for an entity.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `entityId` | `number` | The id of the entity. |
| `input` | `object` | The contact input. |
| `input.contactType` | `string` | The contact type (e.g. `'email'`). |
| `input.contact` | `string` | The contact value. |
| `[input.sort]` | `number` | Optional sort order. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, entityId: number, contactType: string, contact: string, sort: number}>` — The created contact.
**Throws**
`Error` — If the contact type or value is missing.
**Example**
```js
const contact = await store.entitycontact.create(42, 5, { contactType: 'email', contact: 'a@b.c' });
// => { id, entityId, contactType, contact, sort }
```
## `entitycontact.delete`
*Source: `src/store/entitycontact/delete.js`*
Deletes a contact of an entity.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `entityId` | `number` | The id of the entity. |
| `id` | `number` | The id of the contact to delete. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<void>`
**Throws**
`Error` — If the contact is not found.
**Example**
```js
await store.entitycontact.delete(42, 5, 9);
```
## `entitycontact.list`
*Source: `src/store/entitycontact/list.js`*
Lists the contacts of an entity.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `entityId` | `number` | The id of the entity. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<Array<{id: number, entityId: number, contactType: string, contact: string, sort: number}>>` — The contacts.
**Example**
```js
const contacts = await store.entitycontact.list(42, 5);
// => [{ id, entityId, contactType, contact, sort }]
```
## `entitycontact.update`
*Source: `src/store/entitycontact/update.js`*
Updates a contact of an entity.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `entityId` | `number` | The id of the entity. |
| `id` | `number` | The id of the contact to update. |
| `patch` | `object` | The update patch (any subset of contact fields). |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, entityId: number, contactType: string, contact: string, sort: number}>` — The updated contact.
**Throws**
`Error` — If the contact is not found.
**Example**
```js
const contact = await store.entitycontact.update(42, 5, 9, { contact: 'b@c.d' });
// => { id, entityId, contactType, contact, sort }
```