Query Syntax Operators

Last Edit: Sep 25 2020

The Stream Chat API allows you to specify filters and ordering for several endpoints. You can query channels, users, and messages. The query syntax is similar to that of Mongoose.

We do not run MongoDB on the backend. Only a subset of the MongoDB operations are supported.

Please have a look below at the complete list of supported query operations:

Name

Description

Example

$eq

Matches values that are equal to a specified value.

{ "key": { "$eq": "value" } }

or the simplest form

{ "key": "value" }

$gt

Matches values that are greater than a specified value.

{ "key": { "$gt": 4 } }

$gte

Matches values that are greater than or equal to a specified value.

{ "key": { "$gte": 4 } }

$lt

Matches values that are less than a specified value.

{ "key": { "$lt": 4 } }

$lte

Matches values that are less than or equal to a specified value.

{ "key": { "$lte": 4 } }

$ne

Matches all values that are not equal to a specified value.

{ "key": { "$ne": "value" } }

$in

Matches any of the values specified in an array.

{ "key": { "$in": [ 1, 2, 4 ] } }

$nin

Matches none of the values specified in an array.

{ "key": { "$nin": [ 3, 5, 7 ] } }

$and

Matches all the values specified in an array.

{ "$and": [ { "key": { "$in": [ 1, 2, 4 ] } }, { "some_other_key": 10 } ] }

$or

Matches at least one of the values specified in an array.

{ "$or": [ { "key": { "$in": [ 1, 2, 4 ] } }, { "key2": 10 } ] }

$nor

Matches none of the values specified in an array.

{ "$nor": [ { "key": { "$in": [ 1, 2, 4 ] } }, { "key2": 10 } ] }