Search.../

find( )

Returns the items that match the query.

Description

The find() function returns a Promise that resolves to the results found by the query and some information about the results. The Promise is rejected if find() is called with incorrect permissions or if any of the functions used to refine the query are invalid.

Syntax

function find([options: Options]): Promise<MembershipsQueryResult>

find Parameters

NAME
TYPE
DESCRIPTION
options
Optional
Options

Authorization options.

Returns

Fulfilled - The results of a contacts query, containing the retrieved items. When you execute a query with the find() function, it returns a Promise that resolves to a MembershipsQueryResult object. This object contains the items that match the query, information about the query itself, and functions for paging through the query results.

Return Type:

Was this helpful?

Run a query with no filters

Copy Code
1const queryResults = members.queryMemberships().find();
Perform a find on a query

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { groups } from 'wix-groups-backend';
3
4export const myQueryMembershipsFunction = webMethod(Permissions.Anyone, () => {
5
6 return createRequests.queryMemberships()
7 .find()
8 .then((results) => {
9 if (results.items.length > 0) {
10 const items = results.items;
11 const firstItem = items[0];
12 const pageSize = results.pageSize;
13 const totalPages = results.totalPages;
14 const totalCount = results.totalCount;
15 const currentPage = results.currentPage();
16 const next = results.next();
17 const previous = results.prev();
18 const hasNext = results.hasNext();
19 const hasPrev = results.hasPrev();
20 const length = results.length;
21
22 return items;
23 } else {
24 // Handle case where no matching items found
25 }
26 })
27 .catch((error) => {
28 console.error(error);
29 })
30
31});