I have been creating some websocket method on my backend that will use ChangeStream to track data changes in my MongoDb collection. I have this code with a simple pipeline that tries to find records with a certain value in the author.id field:
async fn websocket(socket: WebSocket, state: State<AppState>, user_id: ObjectId) { let (mut sender, _receiver) = socket.split(); let pipeline = vec![doc! { "$match": { "author.id": user_id } }]; let change_stream = state .db .posts_collection .watch(pipeline, None) .await .map_err(|err| { eprintln!("Error creating change stream: {:?}", err); "Failed to create change stream".to_string() }); It does not track changes but if i make my pipeline None it starts to track any changes on the collection, so how to create ChangeStream that gonna track changes only on my matching records?