> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: queryCategories(options: QueryCategoriesOptions) # Method package: wixEventsV2 # Method menu location: wixEventsV2 --> categories --> queryCategories # Method Link: https://dev.wix.com/docs/velo/apis/wix-events-v2/categories/query-categories.md # Method Description: Creates a query to retrieve a list of categories. The `queryCategories()` function builds a query to retrieve a list of categories and returns a [`CategoriesQueryBuilder`](https://dev.wix.com/docs/velo/apis/wix-events-v2/categories/categories-query-builder/eq.md) object. The returned object contains the query definition, which is typically used to run the query using the [`find()`](https://www.wix.com/velo/reference/wix-events-v2/categories/categoriesquerybuilder/find) function. You can refine the query by chaining `CategoriesQueryBuilder` functions onto the query. `CategoriesQueryBuilder` functions enable you to sort, filter, and control the results `queryCategories()` returns. `queryCategories()` runs with these `CategoriesQueryBuilder` defaults, which you can override: - [`limit(50)`](https://www.wix.com/velo/reference/wix-events-v2/categories/categoriesquerybuilder/limit) |PROPERTY |SUPPORTED FILTERS & SORTING |:---:|:---:| |`_id`|[`eq()`](/categories-query-builder/eq)| |`name`|[`eq()`](/categories-query-builder/eq)| |`_createdDate`|[`ascending()`](/categories-query-builder/ascending),[`descending()`](/categories-query-builder/descending)| # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Retrieve all categories (export from backend code) ```javascript import { categories } from 'wix-events.v2'; import { webMethod, Permissions } from 'wix-web-module'; import { elevate } from 'wix-auth'; const elevatedQueryCategories = elevate(categories.queryCategories); export const myQueryCategoriesFunction = webMethod( Permissions.Anyone, async () => { try { const items = await elevatedQueryCategories() .find(); console.log('Categories: ', items); return items; } catch (error) { console.error(error); } }); /* Promise resolves to: * { * "_items": [ * { * "name": "workshop-leather", * "states": [ * "MANUAL" * ], * "_id": "db3e2663-4ed3-43f7-ba68-5d71611702c8", * "_createdDate": "2024-06-20T07:12:41.366Z" * }, * { * "name": "Cosmic Odyssey: Exploring the Mysteries of the ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "a03a6667-2ada-45d6-9835-834351ab995f", * "_createdDate": "2024-04-30T10:31:56.791Z" * }, * { * "name": "Mindful Living Retreat: Nurturing Wellness and ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "eebe3ed6-ffef-46e4-a83a-e883d7ad8fdd", * "_createdDate": "2023-07-13T13:42:12.833Z" * }, * { * "name": "food", * "states": [ * "MANUAL" * ], * "_id": "bd964127-63ff-47e0-92af-8714037de8c9", * "_createdDate": "2023-07-12T12:40:57.129Z" * }, * { * "name": "technology", * "states": [ * "MANUAL" * ], * "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88", * "_createdDate": "2023-07-12T11:07:35.776Z" * }, * { * "name": "science", * "states": [ * "MANUAL" * ], * "_id": "4a69c13e-eb55-47a8-8ccf-9b55198428a0", * "_createdDate": "2023-07-12T10:51:00.029Z" * }, * { * "name": "Professional Leather Handbag, a course by Lili ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "9dadda33-659d-4376-a69d-19d50fad585a", * "_createdDate": "2023-07-11T14:28:07.061Z" * } * ], * "_originQuery": { * "filterTree": { * "$and": [] * }, * "invalidArguments": [], * "encoder": {}, * "transformationPaths": {}, * "sort": [], * "paging": {}, * "pagingMethod": "OFFSET", * "builderOptions": { * "cursorWithEmptyFilterAndSort": true * } * }, * "_limit": 50, * "_totalCount": 8, * "_offset": 0 * } */ ``` ## Query categories ```javascript import { categories } from 'wix-events.v2'; async function myQueryCategoriesFunction() { try { const items = await categories.queryCategories() .find(); console.log('Event categories: ', items); return items; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "_items": [ * { * "name": "workshop-leather", * "states": [ * "MANUAL" * ], * "_id": "db3e2663-4ed3-43f7-ba68-5d71611702c8", * "_createdDate": "2024-06-20T07:12:41.366Z" * }, * { * "name": "Cosmic Odyssey: Exploring the Mysteries of the ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "a03a6667-2ada-45d6-9835-834351ab995f", * "_createdDate": "2024-04-30T10:31:56.791Z" * }, * { * "name": "Mindful Living Retreat: Nurturing Wellness and ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "eebe3ed6-ffef-46e4-a83a-e883d7ad8fdd", * "_createdDate": "2023-07-13T13:42:12.833Z" * }, * { * "name": "food", * "states": [ * "MANUAL" * ], * "_id": "bd964127-63ff-47e0-92af-8714037de8c9", * "_createdDate": "2023-07-12T12:40:57.129Z" * }, * { * "name": "technology", * "states": [ * "MANUAL" * ], * "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88", * "_createdDate": "2023-07-12T11:07:35.776Z" * }, * { * "name": "science", * "states": [ * "MANUAL" * ], * "_id": "4a69c13e-eb55-47a8-8ccf-9b55198428a0", * "_createdDate": "2023-07-12T10:51:00.029Z" * }, * { * "name": "Professional Leather Handbag, a course by Lili ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "9dadda33-659d-4376-a69d-19d50fad585a", * "_createdDate": "2023-07-11T14:28:07.061Z" * } * ], * "_originQuery": { * "filterTree": { * "$and": [] * }, * "invalidArguments": [], * "encoder": {}, * "transformationPaths": {}, * "sort": [], * "paging": {}, * "pagingMethod": "OFFSET", * "builderOptions": { * "cursorWithEmptyFilterAndSort": true * } * }, * "_limit": 50, * "_totalCount": 8, * "_offset": 0 * } */ ``` ---