Search.../

updateCategory( )

Updates an existing category.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function updateCategory(_id: string, category: UpdateCategory): Promise<Category>

updateCategory Parameters

NAME
TYPE
DESCRIPTION
_id
string

Category ID.

category
UpdateCategory

Returns

Updated category.

Return Type:

Promise<
Category
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Category creation timestamp.

_id
string

Category ID.

assignedEventsCount
number

Total number of published events assigned to the category. Deleted events are excluded.

counts
CategoryCounts

The total number of draft and published events assigned to the category.

name
string

Category name.

states
Array<
string
>

Category state. Possible values:

  • MANUAL: Category is created manually by the user.
  • AUTO: Category is created automatically.
  • RECURRING_EVENT: Category is created automatically when publishing recurring events.
  • HIDDEN: Category can't be seen.

Default: MANUAL.

Note: The WIX_EVENTS.MANAGE_AUTO_CATEGORIES permission is required to use other states than MANUAL.

Was this helpful?

updateCategory example

Copy Code
1import { categories } from 'wix-events.v2';
2
3 async function updateCategory(id, category) {
4 try {
5 const result = await categories.updateCategory(id, category);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13