Querying Call Members

When you create or join a call you get a list of call members, however this can return at most 25 members:

// The maximum limit is 25
// The default limit is 25
try await call.get(membersLimit: 25)

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:

// sorting and pagination
let sort = SortParamRequest(direction: 1, field: "user_id")
let result1 = try await call.queryMembers(
    sort: [sort],
    limit: 10
)

// loading the next page
if let next = result1.next {
    let result2 = try await call.queryMembers(sort: [sort], limit: 10, next: next)
}

// filtering
let result2 = try await call.queryMembers(
    filters: ["role": .dictionary(["eq": "admin"])]
)

Sort options

Sorting is supported on these fields:

  • user_id
  • created_at

Filter options

NameTypeDescriptionSupported operators
user_idstringUser ID$in, $eq, $gt, $gte, $lt, $lte, $exists
rolestringThe role of the user$in, $eq, $gt, $gte, $lt, $lte, $exists
customObjectSearch in custom membership data, example syntax: {'custom.color': {$eq: 'red'}}$in, $eq, $gt, $gte, $lt, $lte, $exists
created_atstring, must be formatted as an RFC3339 timestamp (for example 2021-01-15T09:30:20.45Z)Creation time of the user$in, $eq, $gt, $gte, $lt, $lte, $exists
updated_atstring, must be formatted as an RFC3339 timestamp (for example 2021-01-15T09:30:20.45Z)The time of the last update of the user$in, $eq, $gt, $gte, $lt, $lte, $exists

The Stream API allows you to specify filters and ordering for several endpoints. The query syntax is similar to that of Mongoose, however we do not run MongoDB on the backend. Only a subset of the MongoDB operations are supported.

NameDescriptionExample
$eqMatches values that are equal to a specified value.{ "key": { "$eq": "value" } } or the simplest form { "key": "value" }
$qFull text search (matches values where the whole text value matches the specified value){ "key": { "$q": "value } }
$gtMatches values that are greater than a specified value.{ "key": { "$gt": 4 } }
$gteMatches values that are greater than or equal to a specified value.{ "key": { "$gte": 4 } }
$ltMatches values that are less than a specified value.{ "key": { "$lt": 4 } }
$lteMatches values that are less than or equal to a specified value.{ "key": { "$lte": 4 } }
$inMatches any of the values specified in an array.{ "key": { "$in": [ 1, 2, 4 ] } }
$existsMathces values that either have (when set to true) or not have (when set to false) certain attributes{ "key": { "$exists": true } }
$autocompleteMathces values that start with the specified string value{ "key": { "$autocomplete": "value" } }

It’s also possible to combine filter expressions with the following operators:

NameDescriptionExample
$andMatches all the values specified in an array.{ "$and": [ { "key": { "$in": [ 1, 2, 4 ] } }, { "some_other_key": 10 } ] }
$orMatches at least one of the values specified in an array.{ "$or": [ { "key": { "$in": [ 1, 2, 4 ] } }, { "key2": 10 } ] }

© Getstream.io, Inc. All Rights Reserved.