MotorChangeStream

class motor.motor_tornado.MotorChangeStream(collection, pipeline, full_document, resume_after, max_await_time_ms, batch_size, collation, session)

A change stream cursor.

Should not be called directly by application developers. See watch() for example usage.

See also

The MongoDB documentation on

changeStreams

coroutine close()

Close this change stream.

Stops any “async for” loops using this change stream.

coroutine next()

Advance the cursor.

This method blocks until the next change document is returned or an unrecoverable error is raised.

Raises StopAsyncIteration if this change stream is closed.

You can iterate the change stream by calling await change_stream.next() repeatedly, or with an “async for” loop:

async for change in db.collection.watch():
    print(change)