docs
This commit is contained in:
110
API.category.md
Normal file
110
API.category.md
Normal file
@@ -0,0 +1,110 @@
|
||||
# category
|
||||
|
||||
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
||||
|
||||
## `category.addImage`
|
||||
|
||||
*Source: `src/store/category/addImage.js`*
|
||||
|
||||
Adds an image to a category, processing it into AVIF full and thumb variants.
|
||||
|
||||
```js
|
||||
const fn = addImage(pool);
|
||||
const result = await fn(42, 5, imageBuffer);
|
||||
// => { id, fullHash, thumbW, thumbH, thumbHash }
|
||||
```
|
||||
|
||||
## `category.createUnderParent`
|
||||
|
||||
*Source: `src/store/category/createUnderParent.js`*
|
||||
|
||||
Creates a new category under a given parent category.
|
||||
|
||||
```js
|
||||
const fn = createUnderParent(pool);
|
||||
const category = await fn({ googleAuthId: 42, parentId: 5, name: 'Drinks' });
|
||||
// => { id, parentId, sort, name, slug }
|
||||
```
|
||||
|
||||
## `category.delete`
|
||||
|
||||
*Source: `src/store/category/delete.js`*
|
||||
|
||||
Deletes a category, refusing to delete the company's root category.
|
||||
|
||||
```js
|
||||
const fn = del(pool);
|
||||
await fn({ googleAuthId: 42, id: 5 });
|
||||
```
|
||||
|
||||
## `category.deleteImage`
|
||||
|
||||
*Source: `src/store/category/deleteImage.js`*
|
||||
|
||||
Deletes the image of a category.
|
||||
|
||||
```js
|
||||
const fn = deleteImage(pool);
|
||||
const result = await fn(42, 5);
|
||||
// => { id, thumbW: null, thumbH: null, thumbHash: null }
|
||||
```
|
||||
|
||||
## `category.getCategoryArticles`
|
||||
|
||||
*Source: `src/store/category/getCategoryArticles.js`*
|
||||
|
||||
Returns the articles belonging to a single category.
|
||||
|
||||
```js
|
||||
const fn = getCategoryArticles(pool);
|
||||
const articles = await fn(42, 5);
|
||||
// => [{ id, sku, name, ... }]
|
||||
```
|
||||
|
||||
## `category.getTreeForCompany`
|
||||
|
||||
*Source: `src/store/category/getTreeForCompany.js`*
|
||||
|
||||
Returns the full category tree for a company together with its articles and the posterminal ids assigned to each category.
|
||||
|
||||
```js
|
||||
const fn = getTreeForCompany(pool);
|
||||
const tree = await fn(42, 1);
|
||||
// => { languageId, tree: [{ id, posterminalIds, ... }], articles: [...] }
|
||||
```
|
||||
|
||||
## `category.move`
|
||||
|
||||
*Source: `src/store/category/move.js`*
|
||||
|
||||
Moves a category to a new parent, preventing cycles and cross-company moves.
|
||||
|
||||
```js
|
||||
const fn = move(pool);
|
||||
const result = await fn({ googleAuthId: 42, id: 5, parentId: 9 });
|
||||
// => { id, parentId, sort }
|
||||
```
|
||||
|
||||
## `category.order`
|
||||
|
||||
*Source: `src/store/category/order.js`*
|
||||
|
||||
Reorders the child categories of a given parent.
|
||||
|
||||
```js
|
||||
const fn = order(pool);
|
||||
const result = await fn({ googleAuthId: 42, parentId: 5, categoryIds: [3, 1, 2] });
|
||||
// => { categoryIds: [3, 1, 2] }
|
||||
```
|
||||
|
||||
## `category.rename`
|
||||
|
||||
*Source: `src/store/category/rename.js`*
|
||||
|
||||
Renames a category and updates its slug.
|
||||
|
||||
```js
|
||||
const fn = rename(pool);
|
||||
const result = await fn({ googleAuthId: 42, id: 5, name: 'Soft Drinks' });
|
||||
// => { id, name, slug }
|
||||
```
|
||||
Reference in New Issue
Block a user