[CSHARP-4645] WatchAsync() signatures are not consistent Created: 08/May/23 Updated: 08/May/23 Resolved: 08/May/23 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Unknown |
| Reporter: | Magne Ryholt | Assignee: | Boris Dogadov |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
||||||||
| Description |
|
The signature for a MongoCollection.WatchAsync allows a pipeline argument as PipelineDefinition<ChangeStreamDocument<TDocument>, TResult> The signatures for MongoDatabase and MongoClient allows only PipelineDefinition<ChangeStreamDocument<BsonDocument>, TResult> Any particular reason why only Collection accepts a strongly typed pipeline? |
| Comments |
| Comment by Boris Dogadov [ 08/May/23 ] |
|
Thanks for reporting this. Closing this ticket, and will track this issue in |
| Comment by Magne Ryholt [ 08/May/23 ] |
|
Thanks a lot, really helpful. |
| Comment by Boris Dogadov [ 08/May/23 ] |
|
Thanks for the additional information. Yes, the driver does not support rendering namespace queries, we'll be tracking this feature in And you are correct, the workaround for now would be specifying the pipeline via json. |
| Comment by Magne Ryholt [ 08/May/23 ] |
|
Thanks I kind of understand and kind of not the streamed document is of the type defined by the pipeline, which is T for a Collection and just has to be BsonDocument for Database and Client. The BsonDocument from a e.g. Client stream may be deserialized to T anyway. I can solve my "problem" by specifying the pipeline match stage with raw Bson operations, but strongly typing is always safer and more readable. The reason why I ask is for keeping number of connections down because I want to be informed of many of the databases (hundreds), but not all and the pipeline cannot match on e.g. <changeDocument>.DatabaseNamespace.DatabaseName == <some name> because it throws when WatchAsync is called stating that there is no serializer registered for DatabaseNamespace, which, as described above, may be solved by raw Bson (please correct me if I am wrong) I could subscribe for changes from all databases and do the filtering client-side after deserializing to T, but I assume that creates much more network use (and possibly higher load server-side) |
| Comment by Boris Dogadov [ 08/May/23 ] |
|
Hi magne@ryholt.no, thanks for the question. MongoDatabase.Watch watches all collections across the database and MongoClient.Watch watches all collections across all databases. |
| Comment by Service Account: DBX TPM [ 08/May/23 ] |
|
Hi magne@ryholt.no, thank you for reporting this issue! The team will look into it and get back to you soon. |