Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document query call members method #1494

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
id: querying-call-members
title: Querying Call Members
description: How to query call members
---

import FilterConditions from '../../../shared/_filter-operators.mdx';
import CallMemberFilters from '../../../shared/video/_call-member-filters.mdx';
import CallMemberSort from '../../../shared/video/_call-member-sort-fields.mdx';
szuperaz marked this conversation as resolved.
Show resolved Hide resolved

Even though when you create or join a call you get a list of call members, for larger calls this list won't contain all members. To get the complete list of call members the Stream API allows you to query, filter and sort members of a call using a paginated list.

## Examples

Below are a few examples of how to use this API:

```typescript
const result = await call.queryMembers();

// sorting and pagination
const queryMembersReq = {
sort: [{ field: 'user_id', direction: 1 }],
limit: 2,
};
const result = await call.queryMembers(queryMembersReq);

// loading the next page
const result = await call.queryMembers({
...queryMembersReq,
next: result.next,
});

// filtering
const result = await call.queryMembers({
filter_conditions: { role: { $eq: 'admin' } },
});
```

## Sort options

<CallMemberSort />

## Filter options

<CallMemberFilters />

<FilterConditions />
40 changes: 40 additions & 0 deletions packages/client/src/__tests__/Call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,46 @@ describe('state updates in reponse to coordinator API', () => {
await call.leave();
});

it('should query call members', async () => {
await call.getOrCreate({
data: {
members: [
{ user_id: 'sara', role: 'admin' },
{ user_id: 'jane' },
{ user_id: 'jack' },
],
},
});

// default sorting
let result = await call.queryMembers();

expect(result.members.length).toBe(3);

// sorting and pagination
const queryMembersReq = {
sort: [{ field: 'user_id', direction: 1 }],
limit: 2,
};
result = await call.queryMembers(queryMembersReq);

expect(result.members.length).toBe(2);
expect(result.members[0].user_id).toBe('jack');
expect(result.members[1].user_id).toBe('jane');

// loading next page
result = await call.queryMembers({ ...queryMembersReq, next: result.next });

expect(result.members.length).toBe(1);

result = await call.queryMembers({
filter_conditions: { role: { $eq: 'admin' } },
});

expect(result.members.length).toBe(1);
expect(result.members[0].user_id).toBe('sara');
});

afterEach(async () => {
await serverClient.video.call(call.type, call.id).delete({ hard: true });
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
id: querying-call-members
title: Querying Call Members
description: How to query call members
---

import FilterConditions from '../../../shared/_filter-operators.mdx';
import CallMemberFilters from '../../../shared/video/_call-member-filters.mdx';
import CallMemberSort from '../../../shared/video/_call-member-sort-fields.mdx';

Even though when you create or join a call you get a list of call members, for larger calls this list won't contain all members. To get the complete list of call members the Stream API allows you to query, filter and sort members of a call using a paginated list.

## Examples

Below are a few examples of how to use this API:

```typescript
const result = await call.queryMembers();

// sorting and pagination
const queryMembersReq = {
sort: [{ field: 'user_id', direction: 1 }],
limit: 2,
};
const result = await call.queryMembers(queryMembersReq);

// loading the next page
const result = await call.queryMembers({
...queryMembersReq,
next: result.next,
});

// filtering
const result = await call.queryMembers({
filter_conditions: { role: { $eq: 'admin' } },
});
```

## Sort options

<CallMemberSort />

## Filter options

<CallMemberFilters />

<FilterConditions />
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
id: querying-call-members
title: Querying Call Members
description: How to query call members
---

import FilterConditions from '../../../shared/_filter-operators.mdx';
import CallMemberFilters from '../../../shared/video/_call-member-filters.mdx';
import CallMemberSort from '../../../shared/video/_call-member-sort-fields.mdx';

Even though when you create or join a call you get a list of call members, for larger calls this list won't contain all members. To get the complete list of call members the Stream API allows you to query, filter and sort members of a call using a paginated list.

## Examples

Below are a few examples of how to use this API:

```typescript
const result = await call.queryMembers();

// sorting and pagination
const queryMembersReq = {
sort: [{ field: 'user_id', direction: 1 }],
limit: 2,
};
const result = await call.queryMembers(queryMembersReq);

// loading the next page
const result = await call.queryMembers({
...queryMembersReq,
next: result.next,
});

// filtering
const result = await call.queryMembers({
filter_conditions: { role: { $eq: 'admin' } },
});
```

## Sort options

<CallMemberSort />

## Filter options

<CallMemberFilters />

<FilterConditions />
Loading