87 lines
2.1 KiB
Markdown
87 lines
2.1 KiB
Markdown
# brand
|
|
|
|
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
|
|
|
## `brand.delete`
|
|
|
|
*Source: `src/store/brand/delete.js`*
|
|
|
|
Deletes a brand for the user's selected company by its id.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `id` | `number` | The id of the brand to delete. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<void>`
|
|
|
|
**Throws**
|
|
|
|
`Error` — If the brand is not found.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
await store.brand.delete(42, 3);
|
|
```
|
|
|
|
## `brand.list`
|
|
|
|
*Source: `src/store/brand/list.js`*
|
|
|
|
Lists the brands of the user's selected company.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<Array<{id: number, name: string, gsprpinfo: string|null, pics: Array<{id: number, sort: number, fullHash: string, thumbW: number, thumbH: number, thumbHash: string}>}>>` — The brands.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const brands = await store.brand.list(42);
|
|
// => [{ id, name, gsprpinfo, pics: [{ sort, fullHash, thumbW, thumbH, thumbHash }] }]
|
|
```
|
|
|
|
## `brand.upsert`
|
|
|
|
*Source: `src/store/brand/upsert.js`*
|
|
|
|
Creates or updates a brand for the user's selected company, keyed by name.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `input` | `object` | The brand input. |
|
|
| `input.name` | `string` | The brand name. |
|
|
| `[input.gsprpinfo]` | `string` | Optional GSPRP info. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<{id: number, name: string, gsprpinfo: string|null, pics: Array<{id: number, sort: number, fullHash: string, thumbW: number, thumbH: number, thumbHash: string}>}>` — The upserted brand.
|
|
|
|
**Throws**
|
|
|
|
`Error` — If the brand is invalid.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const brand = await store.brand.upsert(42, { name: 'Coca-Cola', gsprpinfo: 'x' });
|
|
// => { id, name, gsprpinfo, pics: [] }
|
|
```
|