> 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: queryGroups() # Method package: wixGroupsBackend # Method menu location: wixGroupsBackend --> Groups --> queryGroups # Method Link: https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/query-groups.md # Method Description: Creates a query to retrieve a list of groups. > **Note:** For `SECRET` groups, only site admins, group admins, and group members can query groups and their content. However, if the `suppressAuth` option is set to `true`, all permissions are overwritten, and all site members (including non-group members) can query groups and their content. The `queryGroups()` function builds a query to retrieve a list of all groups, and returns a [GroupsQueryBuilder](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/introduction.md) object. The returned object contains the query definition which is typically used to run the query using the [`find()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/find.md) function. You can refine the query by chaining `GroupsQueryBuilder` functions onto the query. `GroupsQueryBuilder` functions enable you to sort, filter, and control the results that `queryGroups()` returns. `queryGroups()` runs with these `GroupsQueryBuilder` defaults, which you can override: + [`limit(1000)`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/limit.md) + [`descending("_createdDate")`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/descending.md) The following `GroupsQueryBuilder` functions are supported for `queryGroups()`. For a full description of the Groups object, see the object returned for the [`items`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-result/items.md) property in [`GroupsQueryResult`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-result/introduction.md). | Property | Supported Filters & Sorting | | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `name` | [`eq()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/eq.md), [`ne()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/ne.md), [`startsWith()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/starts-with.md), [`endsWith()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/ends-with.md), [`contains()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/contains.md),[`hasSome()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/has-some.md), [`ascending()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/descending.md), [`or()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/or.md) | | `_createdDate` | [`ascending()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/descending.md) | | `memberCount` | [`ascending()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/descending.md) | | `lastActivityDate` | [`ascending()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/apis/wix-groups-backend/groups/groups-query-builder/descending.md) | # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Query groups ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { groups } from 'wix-groups-backend'; export const myQueryGroupsFunction = webMethod(Permissions.Anyone, () => { return groups.queryGroups() .find() .then((results) => { const items = results.items; const firstItem = items[0]; const pageSize = results.pageSize; const totalPages = results.totalPages; const totalCount = results.totalCount; const currentPage = results.currentPage(); const next = results.next(); const previous = results.prev(); const hasNext = results.hasNext(); const hasPrev = results.hasPrev(); const length = results.length; return items; }) .catch((error) => { console.error(error); }); }); /* Returns items: * [ * { * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7" * "name": "My Group 1" * "slug": "my-group-1" * "description": "Welcome to the group! You can connect with other members, get updates and share videos." * "privacyStatus": "PUBLIC" * "coverImage": { * "imageUrl": "wix:image://v1/zc0974e348009011fa9f2d29zc~mv2.jpg/pickles.jpg#originWidth=607&originHeight=670", * "position": { * "x": 500, * "y": 500 * } * } * "memberCount": 83 * "settings": { * "groupUpdatePostEnabled": true * "membersCanApprove": false * "membersCanInvite": true * "showMemberList": true * "welcomeMemberPostEnabled": true * } * "lastActivityDate": "Sun Sep 26 2021 08:23:23 GMT+0300" * "_createdDate": "Tues January 22 2021 12:56:02 GMT+0300" * "_updatedDate": "Fri October 2 2021 04:56:22 GMT+0300" * "owner": "9ne8e9e1-d050-4c86-9684-e7f231600a34" * }, * { * "_id": "6ff5333-b477-4e9tt-ba4j-df338c5ad6221" * "name": "My Group 2" * "slug": "my-group-2" * "description": "Welcome to the group! You can connect with other members, get updates and share videos." * "privacyStatus": "PRIVATE" * "coverImage": { * "imageUrl": "wix:image://v1/q224e348009011fa9f2d29kk099~mv2.jpg/maple.jpg#originWidth=465&originHeight=448", * "position": { * "x": 24, * "y": 34 * } * } * "memberTitle": "Friends" * "memberCount": 68 * "settings": { * "groupUpdatePostEnabled": true * "membersCanApprove": true * "membersCanInvite": true * "showMemberList": false * "welcomeMemberPostEnabled": true * } * "lastActivityDate": "Thurs Nov 12 2020 11:13:03 GMT+0300" * "_createdDate": "Wed May 14 2020 10:05:20 GMT+0300" * "_updatedDate": "Sun June 7 2020 09:07:33 GMT+0300" * "owner": "abe5e4e1-d950-4c46-8884-e7f231600d67" * } * ] */ ``` ---