Navigation

Watch for Document Changes

On this page

Overview

MongoDB Realm allows you to watch a collection and receive client-side database events whenever documents in the collection are inserted or modified. This enables you to develop real-time and collaborative applications without the overhead and complexity of alternatives such as long polling.

Realm uses MongoDB change streams on watched collections to listen for changes and broadcast them to any client applications that are watching documents in the collection at the time of the event. Realm supports watching any change on a collection and watching changes that match a certain filter.

Change Stream Limitations

Realm opens a single MongoDB change stream for each watched collection and limits the total number of open change streams on each linked cluster across all Realm apps based on the cluster’s size. See change stream limitations for more information.

Examples

For code examples of watching collections, refer to the client SDKs:

To watch for changes to a collection from the Android Client SDK, see the Android SDK documentation for change streams.

To watch for changes to a collection from the Node Client SDK, see the Node SDK documentation for change streams.

To watch for changes to a collection from the React Native Client SDK, see the React Native SDK documentation for change streams.

To watch for changes to a collection from the Web Client SDK, see the Web SDK documentation for change streams.