groups.findAllWithSpecificMembers()

Find a group by a list of member identifiers.

Definition

client.groups.findAllWithSpecificMembers(
memberIds: string | string[] | User[],
organizationId: string | Organization,
options: Object | null | undefined
):Promise<Group[],Error>

Parameters

ParameterTypeDescription
memberIdsstring[] | User[]The user ID or user model
organizationIdstring | OrganizationThe organization ID within which to search for the group
optionssee belowOptions to apply to the search

Options

OptionTypeDescription
localOnlyboolean (default: false)If true, the search will only check the groups that the client already knows about, rather than making a request to the API server.
exactboolean (default: true)If true, the search will only check for exact member matches. If false, the search will include any groups that the specified members are all part of.
includeCurrentUserboolean (default: true)If true, the search will include the current user in the search. If false, the search will use only the ids specified in the memberIds parameter.
includeForumsboolean (default: true)Whether the search results will include forum groups.
includeRolesboolean (default: true)When exact: true is specified, this option allows specifying that the current user's roles should also be checked against for matches within the group.

Returns

An error will be thrown if the operation failed, otherwise the Promise will resolve.

Examples

Search for a group with the current user and 3 other specific users

const groupsForUsers = await client.groups.findAllWithSpecificMembers(
['user-id-1', 'user-id-2', 'user-id-3'],
'my-organization-id',
{}
);
console.log(`found ${groupsForUsers.length} existing groups containing users 1, 2, and 3`);

Search for all groups containing 2 specific users, without the current user being required

const groupsContainingUsers4and5 = await client.groups.findAllWithSpecificMembers(
['user-id-4', 'user-id-5'],
'my-organization-id',
{
includeCurrentUser: false,
exact: false,
}
);

Search for all groups the current user is in with at least users 6 and 7, but only if the user is in the group as a user (exclude roles)

const groupsContainingMyUserOnlyAndUsers6and7 = await client.groups.findAllWithSpecificMembers(
['user-id-6', 'user-id-7'],
'my-organization-id',
{
includeCurrentUser: false,
includeRoles: false,
}
);