Search.../

queryPolicies( )

Developer Preview

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.

PROPERTYSUPPORTED FILTERS & SORTING
ideq(),ne(),in(),exists(),ascending(),descending()
revisioneq(),ne(),in(),lt(),le(),gt(),ge(),exists(),ascending(),descending()
createdDateeq(),ne(),in(),lt(),le(),gt(),exists(),ascending(),descending()
updatedDateeq(),ne(),in(),lt(),le(),gt(),exists(),ascending(),descending()
nameeq(),ne(),in(),exists(),ascending(),descending()
bodyeq(),ne(),in(),exists(),ascending(),descending()
eventIdeq(),ne(),in(),exists(),ascending(),descending()

Syntax

function queryPolicies(): PoliciesQueryBuilder

queryPolicies Parameters

This function does not take any parameters.

Returns

Was this helpful?

Query Policies by name and sort by _createdDate in descending order

Copy Code
1import { policies } from 'wix-events.v2';
2
3//query policies
4async 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 error
15 }
16 };
17
18/* Returns all found policies
19{
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": true
61 }
62 },
63 "_limit": 50,
64 "_nextCursor": "",
65 "_prevCursor": "",
66 "cursors": {
67 "next": "",
68 "prev": ""
69 }
70}
71*/