Skip to content

Commit

Permalink
docs: document query call members method
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Sep 24, 2024
1 parent 75ed99c commit fcb5822
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 0 deletions.
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 />
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 />

0 comments on commit fcb5822

Please sign in to comment.