# warehouse This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`. ## `warehouse.create` *Source: `src/store/warehouse/create.js`* Creates a new warehouse for the user's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `input` | `object` | Warehouse input. | | `input.name` | `string` | The warehouse name. | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise<{id: number, name: string}>` — The created warehouse. **Throws** `Error` — If name is missing or already exists. **Example** ```js const wh = await store.warehouse.create(googleAuthId, { name: 'Hauptlager' }); // => { id: 1, name: 'Hauptlager' } ``` ## `warehouse.delete` *Source: `src/store/warehouse/delete.js`* Deletes a warehouse for the user's selected company, unless referenced in the ledger. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `id` | `number` | The warehouse ID to delete. | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise` **Throws** `Error` — If warehouse not found or is in use in the ledger. **Example** ```js await store.warehouse.delete(googleAuthId, 1); ``` ## `warehouse.getById` *Source: `src/store/warehouse/getById.js`* Retrieves a warehouse by its ID for the user's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `id` | `number` | The warehouse ID. | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise<{id: number, name: string}|undefined>` — The warehouse or undefined. **Example** ```js const wh = await store.warehouse.getById(googleAuthId, 1); // => { id: 1, name: 'Hauptlager' } ``` ## `warehouse.list` *Source: `src/store/warehouse/list.js`* Lists all warehouses 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>` — List of warehouses. **Example** ```js const warehouses = await store.warehouse.list(googleAuthId); // => [{ id: 1, name: 'Hauptlager' }] ``` ## `warehouse.update` *Source: `src/store/warehouse/update.js`* Updates a warehouse name for the user's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `id` | `number` | The warehouse ID to update. | | `input` | `object` | Update payload. | | `input.name` | `string` | The new warehouse name. | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise<{id: number, name: string}>` — The updated warehouse. **Throws** `Error` — If warehouse not found, name is missing, or name already exists. **Example** ```js const updated = await store.warehouse.update(googleAuthId, 1, { name: 'Zentrallager' }); // => { id: 1, name: 'Zentrallager' } ```