queryPolicies( )
Creates a query to retrieve a list of policies, given the provided paging and filter.
Description
The queryPolicies()
function builds a query to retrieve a list of policies and returns a PoliciesQueryBuilder object.
The returned object contains the query definition which is typically used to run the query using the 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
: 50
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() ,ne() ,in() ,exists() ,ascending() ,descending() |
revision | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,exists() ,ascending() ,descending() |
_createdDate | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,exists() ,ascending() ,descending() |
_updatedDate | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,exists() ,ascending() ,descending() |
name | eq() ,ne() ,in() ,exists() ,ascending() ,descending() |
body | eq() ,ne() ,in() ,exists() ,ascending() ,descending() |
eventId | eq() ,ne() ,in() ,exists() ,ascending() ,descending() |
Syntax
function queryPolicies(): PoliciesQueryBuilder
queryPolicies Parameters
This function does not take any parameters.
Returns
Return Type:
Was this helpful?
1import { policies } from 'wix-events.v2';23//query policies4async function queryPolicies() {5 try {6 const items = await policies.queryPolicies()7 .eq('eventId', '3d3d5c04-ece0-45a8-85f0-11a58edaa192')8 .ascending('_createdDate')9 .find();10 return items;11 }12 catch (error) {13 console.error(error);14 // Handle the error15 }16 };1718/* Returns all found policies19{20 "_items": [21 {22 "_id": "96b39980-e4e1-44e3-9ef0-9bec41d1cc10",23 "revision": "6",24 "_createdDate": "2023-03-08T13:55:18.057Z",25 "_updatedDate": "2023-03-15T13:43:11.794Z",26 "name": "Terms and Conditions Event 2",27 "body": "<p>Nobody will be allowed admission to the Event without a valid ticket or pass.</p>",28 "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"29 },30 {31 "_id": "850beadf-f367-4197-a0c8-6624cb3bcef9",32 "revision": "1",33 "_createdDate": "2023-03-15T13:49:27.023Z",34 "_updatedDate": "2023-03-15T13:49:27.023Z",35 "name": "Terms and Conditions Event 1",36 "body": "<p>Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.</p>",37 "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"38 }39 ],40 "_originQuery": {41 "filterTree": {42 "$and": [43 {44 "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"45 }46 ]47 },48 "invalidArguments": [],49 "encoder": {},50 "transformationPaths": {},51 "sort": [52 {53 "fieldName": "createdDate",54 "order": "ASC"55 }56 ],57 "paging": {},58 "pagingMethod": "CURSOR",59 "builderOptions": {60 "cursorWithEmptyFilterAndSort": true61 }62 },63 "_limit": 50,64 "_nextCursor": "",65 "_prevCursor": "",66 "cursors": {67 "next": "",68 "prev": ""69 }70}71*/
1import { Permissions, webMethod } from 'wix-web-module';2import { policies } from 'wix-events.v2';34export const queryPolicies = webMethod(Permissions.Anyone, async () => {5 try {6 const items = await policies.queryPolicies()7 .eq('eventId', '3d3d5c04-ece0-45a8-85f0-11a58edaa192')8 .ascending('_createdDate')9 .find();10 return items;11 } catch (error) {12 console.error(error);13 // Handle the error14 }15});1617/* Promise resolves to:18 * {19 * "_items": [20 * {21 * "_id": "96b39980-e4e1-44e3-9ef0-9bec41d1cc10",22 * "revision": "6",23 * "_createdDate": "2023-03-08T13:55:18.057Z",24 * "_updatedDate": "2023-03-15T13:43:11.794Z",25 * "name": "Terms and Conditions Event 2",26 * "body": "<p>Nobody will be allowed admission to the Event without a valid ticket or pass.</p>",27 * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"28 * },29 * {30 * "_id": "850beadf-f367-4197-a0c8-6624cb3bcef9",31 * "revision": "1",32 * "_createdDate": "2023-03-15T13:49:27.023Z",33 * "_updatedDate": "2023-03-15T13:49:27.023Z",34 * "name": "Terms and Conditions Event 1",35 * "body": "<p>Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.</p>",36 * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"37 * }38 * ],39 * "_originQuery": {40 * "filterTree": {41 * "$and": [42 * {43 * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"44 * }45 * ]46 * },47 * "invalidArguments": [],48 * "encoder": {},49 * "transformationPaths": {},50 * "sort": [51 * {52 * "fieldName": "createdDate",53 * "order": "ASC"54 * }55 * ],56 * "paging": {},57 * "pagingMethod": "CURSOR",58 * "builderOptions": {59 * "cursorWithEmptyFilterAndSort": true60 * }61 * },62 * "_limit": 50,63 * "_nextCursor": "",64 * "_prevCursor": "",65 * "cursors": {66 * "next": "",67 * "prev": ""68 * }69 * }70 */71