RUST-1986 In 3.0.0, Collection::watch ignores the collection type parameter
It seems that in 3.0.0 the .watch() method always returns a stream of ChangeStreamEvent<mongodb::bson::Document>? This seems unfortunate given that in 2.8.2 watch respected the T param of Collection.
Also, I don't see this change mentioned in the update notes.
let coll: Collection<bson::RawDocumentBuf> = ...;
let mut stream = coll.watch().await?;
// ERROR: cannot convert from `std::option::Option<ChangeStreamEvent<mongodb::bson::Document>>` to `std::option::Option<ChangeStreamEvent<RawDocumentBuf>>`
let doc: Option<bson::RawDocumentBuf> = stream.next().await.transpose()?;
Seems related to https://github.com/mongodb/mongo-rust-driver/issues/1153
Oh I see now that there is also with_type on ChangeStream, so with this change it works as before:
let mut stream = coll.watch().await?.with_type::<ChangeStreamEvent<bson::RawDocumentBuf>>();
Then I guess this is the intended usage and this issue can be closed?
This was an oversight and an unintended regression, we'll get a fix out shortly.
We've just released version 3.0.1 that includes the fix for this.