Files
dashlibstorage/API.brand.md
2026-10-11 03:30:26 +02:00

5.2 KiB

brand

This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.

brand.addImage

Source: src/store/brand/addImage.js

Adds an image to a brand, processing full, thumb, and 32px-edge small-thumb AVIF variants.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
brandId number The id of the brand.
image Buffer The source image buffer.
[tx] object Optional transaction to run within.

Returns

Promise<{id: number, fullHash: string, thumbW: number, thumbH: number, thumbHash: string, smallThumbW: number, smallThumbH: number, pics: Array<object>}>

brand.create

Source: src/store/brand/create.js

Creates a brand for the user's selected company.

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<{fullHash: string, thumbW: number, thumbH: number, thumbHash: string}>}> — The created brand.

Throws

Error — If the brand is invalid or already exists.

Example

const brand = await store.brand.create(42, { name: 'Coca-Cola', gsprpinfo: 'x' });
// => { id, name, gsprpinfo, pics: [] }

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

await store.brand.delete(42, 3);

brand.list

Source: src/store/brand/list.js

Lists the brands of the user's selected company, sorted by name.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
[opts] object Optional pagination options.
[opts.offset=0] number Number of brands to skip.
[opts.limit=10] number Number of brands to return (max 100).
[opts.includeSmallThumbs=false] boolean Include 32px-edge small thumbnail dimensions and base64 AVIF data.
[tx] object Optional transaction to run within.

Returns

Promise<{brands: Array<{id: number, name: string, articleCount: number, gsprpinfo: string|null, pics: Array<{fullHash: string, thumbW: number, thumbH: number, thumbHash: string, smallThumbW?: number|null, smallThumbH?: number|null, smallThumbBinary?: string|null}>}>, total: number, offset: number, limit: number}> — The brands plus the total unpaged count. Small-thumbnail fields are present only when includeSmallThumbs is true; the binary is base64-encoded AVIF data.

Example

const result = await store.brand.list(42, { offset: 0, limit: 10 });
// => { brands: [{ id, name, articleCount, gsprpinfo, pics: [...] }], total: 25, offset: 0, limit: 10 }

brand.update

Source: src/store/brand/update.js

Renames/updates a brand for the user's selected company by id. Touching article.updated_at for all articles linked via brand_id when the name actually changes, so list caches invalidate.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
id number The id of the brand to update.
input object The update input.
[input.name] string The new brand name.
[input.gsprpinfo] string The new GSPRP info.
[tx] object Optional transaction to run within.

Returns

Promise<{id: number, name: string, gsprpinfo: string|null, touchedArticleCount: number}> — The updated brand plus the number of linked articles whose updated_at was bumped.

Throws

Error — If the brand is not found, invalid, or the name is already taken.

Example

const brand = await store.brand.update(42, 3, { name: 'Coca-Cola GmbH' });
// => { id: 3, name, gsprpinfo, touchedArticleCount: 2 }

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<{fullHash: string, thumbW: number, thumbH: number, thumbHash: string}>}> — The upserted brand.

Throws

Error — If the brand is invalid.

Example

const brand = await store.brand.upsert(42, { name: 'Coca-Cola', gsprpinfo: 'x' });
// => { id, name, gsprpinfo, pics: [] }