[CSHARP-3035] RunCommand API doesn't support to return a IAsyncCursor<> type Created: 31/Mar/20 Updated: 27/Oct/23 Resolved: 18/May/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Aiolos Wong | Assignee: | Jeffrey Yemin |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Currently, the runcommand API in MongoDatabaseImpl class doesn't support to return a IAsyncCursor<> type. In many advanced scenario, such as dynamic query, we need runcommand API to return a cursor. So I wonder when the csharper driver shall provide this feature like the go driver in https://github.com/mongodb/mongo-go-driver/blob/master/mongo/database.go |
| Comments |
| Comment by Jeffrey Yemin [ 29/Apr/20 ] |
|
I do mean the methods in IMongoCollection. There is no reason I can think of why a script couldn't call the find method with a dynamic query filter or similar but with an aggregation pipeline, rather than using RunCommand directly. |
| Comment by Aiolos Wong [ 29/Apr/20 ] |
|
Hi jeff.yemin, I checked the source code of the MongoDB csharp driver and found only a private type FindHelper method, nothing about the AggregateHelper method. Do you mean to use the the Find/Aggregate method in IMongoCollection<>? I think what you say about fetching data with a BsonDocument to specify the filter is feasible in most scenarios. But my current reqirement is the ability to execute scripts. Let's say we are developing a data center software and we need to quickly generate various APIs to meet the business requirements for reading data. The users of this feature are developers, not customers. How do we quickly implement this feature? Since the developer understands MongoDB's command query language, he can directly specify a command to get data like the sample in https://docs.mongodb.com/manual/reference/command/find/ and https://docs.mongodb.com/manual/reference/command/aggregate/. If the RunCommand API can return an IAsyncCursor<> type, then developers can easily get the desired data with strong scalability. |
| Comment by Jeffrey Yemin [ 08/Apr/20 ] |
|
Thanks lxyqwd@163.com for the information. But I am still not clear why you can't use the aggregate or find helper method, and build up the filter based on the criteria. Either way, you can use a BsonDocument to specify the filter, so I don't quite see the advantage of RunCommand. There is also quite a bit of behavior that the helper methods provide over RunCommand. In particular, the driver will do automatic retries of failed aggregate or find when using the helpers, but not when using RunCommand. |
| Comment by Aiolos Wong [ 08/Apr/20 ] |
|
Hi jeff.yemin For instance, let's say we were developing a software like Power BI, which needs to read data from MongoDB to generate charts and reports. The customer can select some fields from any collection by using some criterias to filter and aggreate the data. In this scenario, we need to generate a command based on the user's choice and send it to MongoDB to get the data. |
| Comment by Jeffrey Yemin [ 06/Apr/20 ] |
|
Thanks for the request. Can you provide some more specifics about what you mean by "dynamic query"? We'd like to understand the use case a bit better before committing to a new public API. |