odmantic icon indicating copy to clipboard operation
odmantic copied to clipboard

Support for tailable cursors

Open vd2org opened this issue 3 years ago • 2 comments

Support for tailable cursors in engine.find call:

https://motor.readthedocs.io/en/stable/examples/tailable-cursors.html

vd2org avatar Oct 24 '20 13:10 vd2org

Hi, can you describe the behavior you would like to have with the current AIOCursor ?

art049 avatar Oct 24 '20 19:10 art049

Hi! Same as simple find, but I want to wait until new documents come in. This will be useful, for example, for implementing event notifications over websocket.

Something like that:

async for rec of engine.find(EventsModel, EventsModel.timestamp >= datetime.utcnow().timestamp(), tailable=True):
   await websocket.send(dict(rec))

vd2org avatar Oct 28 '20 22:10 vd2org