Skip to content

Live Updates of a Collection​

GET
/mongodb/collections/{collectionName}/documents/watch

The changes of the documents as Server-Sent Events (2.3.0), scoped like every read and by filter. Events: upsert (data { id, document }, a document that is in the scope), remove (data { id }, deleted or left the scope), reset (the client loads again). With followRefs=true and expand (2.10.0) a change of a referenced document sends upsert (without id) for the documents that refer to it, refresh when more than 100 do (the client loads again). The id of an event is the resume token: send it as Last-Event-ID to resume. A comment every 25 seconds. Needs a replica set or a sharded cluster: 501 (code 5011) otherwise; at most WATCH_MAX_STREAMS streams per instance (503).

Parameters​

Header Parameters

Last-Event-ID

The id of the last event the client got, to resume after it.

Type
string

Path Parameters

collectionName*

The name of your MongoDb Collection

Type
string
Required

Query Parameters

expand

References to expand in each upsert (2.4.0), like on the list of documents. A change of a referenced document sends no event, unless followRefs (2.10.0).

Type
array
followRefs

With expand (2.10.0): a change of a referenced document sends upsert for the documents that refer to it (refresh beyond 100).

Type
boolean
filter

Lucene filter of the documents to watch.

Type
string
filterCaseInsensitive
Type
boolean

Responses​

text/event-stream

text/event-stream
JSON
"string"

Playground​

Headers
Variables
Key
Value

Samples​

Powered by VitePress OpenAPI

Released under the MIT License.