# 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. | **Returns** `Promise` **Throws** `Error` — If the unit is not found. **Example** ```js 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. | **Returns** `Promise>` — The units. **Example** ```js 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. | **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** ```js const unit = await store.unit.upsert(42, { si: 'l', basesi: 'm3', basesifactor: 0.001, symbol: 'L', name: 'Liter' }); // => { id, si, basesi, basesifactor, symbol, name } ```