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

2.1 KiB

unit

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

unit.delete

Source: src/store/unit/delete.js

Deletes a unit for the user's selected company by its SI code.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
si string The SI code of the unit to delete.
[tx] object Optional transaction to run within.

Returns

Promise<void>

Throws

Error — If the unit is not found.

Example

await store.unit.delete(42, 'l');

unit.list

Source: src/store/unit/list.js

Lists the units available for 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, si: string, basesi: string, basesifactor: number, symbol: string, name: string}>> — The units.

Example

const units = await store.unit.list(42);
// => [{ id, si, basesi, basesifactor, symbol, name }]

unit.upsert

Source: src/store/unit/upsert.js

Creates or updates a unit for the user's selected company, keyed by its SI code.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
input object The unit input.
input.si string The SI code.
input.basesi string The base SI code.
input.basesifactor number The base SI factor (must be > 0).
input.symbol string The unit symbol.
input.name string The unit name.
[tx] object Optional transaction to run within.

Returns

Promise<{id: number, si: string, basesi: string, basesifactor: number, symbol: string, name: string}> — The upserted unit.

Throws

Error — If the unit is invalid.

Example

const unit = await store.unit.upsert(42, { si: 'l', basesi: 'm3', basesifactor: 0.001, symbol: 'L', name: 'Liter' });
// => { id, si, basesi, basesifactor, symbol, name }