> 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: queryPolicies() # Method package: wixEventsV2 # Method menu location: wixEventsV2 --> policies --> queryPolicies # Method Link: https://dev.wix.com/docs/velo/apis/wix-events-v2/policies/query-policies.md # Method Description: Creates a query to retrieve a list of policies, given the provided paging and filter. The `queryPolicies()` function builds a query to retrieve a list of policies and returns a [PoliciesQueryBuilder](https://www.wix.com/velo/reference/wix-events-v2/policies/policiesquerybuilder) 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/policies/policiesquerybuilder/find) function. You can refine the query by chaining `PoliciesQueryBuilder` functions onto the query. `PoliciesQueryBuilder` functions enable you to sort, filter and control the results that `PoliciesQueryBuilder.find()` returns. The query runs with the following `PoliciesQueryBuilder` defaults that you can override: [`limit`](https://www.wix.com/velo/reference/wix-events-v2/policies/policiesquerybuilder/limit): `50` [`descending`](https://www.wix.com/velo/reference/wix-events-v2/policies/policiesquerybuilder/descending): `_createdDate` The functions that are chained to `queryPolicies()` are applied in the order they are called. For example, if you sort on the `_createdDate` property in ascending order and then on the id property in descending order, the results are sorted by the created date and then, if there are multiple results with the same date, the items are sorted by the id. The table below shows which `PoliciesQueryBuilder` functions are supported for `queryPoliciesGuests()`. You can only use one filter function for each property. If a property is used in more than one filter, only the first filter will work. |PROPERTY |SUPPORTED FILTERS & SORTING |:---:|:---:| |`_id`|[`eq()`](/policies-query-builder/eq),[`ne()`](/policies-query-builder/ne),[`in()`](/policies-query-builder/in),[`exists()`](/policies-query-builder/exists),[`ascending()`](/policies-query-builder/ascending),[`descending()`](/policies-query-builder/descending)| |`revision`|[`eq()`](/policies-query-builder/eq),[`ne()`](/policies-query-builder/ne),[`in()`](/policies-query-builder/in),[`lt()`](/policies-query-builder/lt),[`le()`](/policies-query-builder/le),[`gt()`](/policies-query-builder/gt),[`ge()`](/policies-query-builder/ge),[`exists()`](/policies-query-builder/exists),[`ascending()`](/policies-query-builder/ascending),[`descending()`](/policies-query-builder/descending)| |`_createdDate`|[`eq()`](/policies-query-builder/eq),[`ne()`](/policies-query-builder/ne),[`in()`](/policies-query-builder/in),[`lt()`](/policies-query-builder/lt),[`le()`](/policies-query-builder/le),[`gt()`](/policies-query-builder/gt),[`ge()`](/policies-query-builder/ge),[`exists()`](/policies-query-builder/exists),[`ascending()`](/policies-query-builder/ascending),[`descending()`](/policies-query-builder/descending)| |`_updatedDate`|[`eq()`](/policies-query-builder/eq),[`ne()`](/policies-query-builder/ne),[`in()`](/policies-query-builder/in),[`lt()`](/policies-query-builder/lt),[`le()`](/policies-query-builder/le),[`gt()`](/policies-query-builder/gt),[`ge()`](/policies-query-builder/ge),[`exists()`](/policies-query-builder/exists),[`ascending()`](/policies-query-builder/ascending),[`descending()`](/policies-query-builder/descending)| |`name`|[`eq()`](/policies-query-builder/eq),[`ne()`](/policies-query-builder/ne),[`in()`](/policies-query-builder/in),[`exists()`](/policies-query-builder/exists),[`ascending()`](/policies-query-builder/ascending),[`descending()`](/policies-query-builder/descending)| |`body`|[`eq()`](/policies-query-builder/eq),[`ne()`](/policies-query-builder/ne),[`in()`](/policies-query-builder/in),[`exists()`](/policies-query-builder/exists),[`ascending()`](/policies-query-builder/ascending),[`descending()`](/policies-query-builder/descending)| |`eventId`|[`eq()`](/policies-query-builder/eq),[`ne()`](/policies-query-builder/ne),[`in()`](/policies-query-builder/in),[`exists()`](/policies-query-builder/exists),[`ascending()`](/policies-query-builder/ascending),[`descending()`](/policies-query-builder/descending)| # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Query Policies by name and sort by _createdDate in descending order ```javascript import { policies } from 'wix-events.v2'; //query policies async function queryPolicies() { try { const items = await policies.queryPolicies() .eq('eventId', '3d3d5c04-ece0-45a8-85f0-11a58edaa192') .ascending('_createdDate') .find(); return items; } catch (error) { console.error(error); // Handle the error } }; /* Returns all found policies { "_items": [ { "_id": "96b39980-e4e1-44e3-9ef0-9bec41d1cc10", "revision": "6", "_createdDate": "2023-03-08T13:55:18.057Z", "_updatedDate": "2023-03-15T13:43:11.794Z", "name": "Terms and Conditions Event 2", "body": "

Nobody will be allowed admission to the Event without a valid ticket or pass.

", "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192" }, { "_id": "850beadf-f367-4197-a0c8-6624cb3bcef9", "revision": "1", "_createdDate": "2023-03-15T13:49:27.023Z", "_updatedDate": "2023-03-15T13:49:27.023Z", "name": "Terms and Conditions Event 1", "body": "

Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.

", "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192" } ], "_originQuery": { "filterTree": { "$and": [ { "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192" } ] }, "invalidArguments": [], "encoder": {}, "transformationPaths": {}, "sort": [ { "fieldName": "createdDate", "order": "ASC" } ], "paging": {}, "pagingMethod": "CURSOR", "builderOptions": { "cursorWithEmptyFilterAndSort": true } }, "_limit": 50, "_nextCursor": "", "_prevCursor": "", "cursors": { "next": "", "prev": "" } } */ ``` ## Query Policies by name and sort by _createdDate in descending order (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { policies } from 'wix-events.v2'; export const queryPolicies = webMethod(Permissions.Anyone, async () => { try { const items = await policies.queryPolicies() .eq('eventId', '3d3d5c04-ece0-45a8-85f0-11a58edaa192') .ascending('_createdDate') .find(); return items; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "_items": [ * { * "_id": "96b39980-e4e1-44e3-9ef0-9bec41d1cc10", * "revision": "6", * "_createdDate": "2023-03-08T13:55:18.057Z", * "_updatedDate": "2023-03-15T13:43:11.794Z", * "name": "Terms and Conditions Event 2", * "body": "

Nobody will be allowed admission to the Event without a valid ticket or pass.

", * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192" * }, * { * "_id": "850beadf-f367-4197-a0c8-6624cb3bcef9", * "revision": "1", * "_createdDate": "2023-03-15T13:49:27.023Z", * "_updatedDate": "2023-03-15T13:49:27.023Z", * "name": "Terms and Conditions Event 1", * "body": "

Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.

", * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192" * } * ], * "_originQuery": { * "filterTree": { * "$and": [ * { * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192" * } * ] * }, * "invalidArguments": [], * "encoder": {}, * "transformationPaths": {}, * "sort": [ * { * "fieldName": "createdDate", * "order": "ASC" * } * ], * "paging": {}, * "pagingMethod": "CURSOR", * "builderOptions": { * "cursorWithEmptyFilterAndSort": true * } * }, * "_limit": 50, * "_nextCursor": "", * "_prevCursor": "", * "cursors": { * "next": "", * "prev": "" * } * } */ ``` ---