Query Members
Query Channel Members
The ability to search for and query members within a chat channel is an essential feature for creating a seamless and engaging user experience. With social.plus Chat SDK, developers can use the query member feature to allow users to search for and retrieve member information within a channel. We will discuss how to use the query member feature of social.plus Chat SDK to enable users to search and retrieve member information within a chat channel.
Here's an explanation of the function parameter:
filter: A parameter accepting a filter enum, enabling filtering members with matching membership status.
ALL-> Members with any membership statusMEMBER-> Only active membersMUTED-> Only muted membersBANNED-> Only banned members
roles : A parameter accepting an array of roles, enabling filtering members with matching roles
includeDeleted : A parameter accepting a boolean value.
true-> include a member whose user has been deletedfalse-> exclude member whose user has been deleted
sortBy : A parameter accepting a sorting option enum
FIRST_CREATED-> Sort by membership creation date ascendingLAST_CREATED-> Sort by membership creation date ascending
Note: The membership creation date is the time the user joins the channel.
All participation-related methods in a channel fall under a separate ChannelParticipation class.
All participation related methods in a channel fall under a separate ChannelParticipation class.
You can get a list of all members, or add memberships, roles , search parameters to get certain members of the channel.
import { ChannelRepository, MemberFilter } from '@amityco/js-sdk';
let members;
const liveCollection = ChannelRepository.queryMembers({
channelId: 'channel1',
memberships: [MemberFilter.Member],
roles: ['role1'],
search: 'asd',
});
liveCollection.on('dataUpdated', newModels => {
members = newModels;
});
liveCollection.on('dataError', error => {
console.error(error);
});
members= liveCollection.models;Version 6
Beta (v0.0.1)
Last updated
Was this helpful?