Azure / Azure/azure-sdk-for-rust
Cosmos: Add ReadMany API Support
- Dominant language
- Rust
- Stars
- 884
- Forks
- 365
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 109
Description
**Background:**
The Cosmos DB ReadMany API enables clients to retrieve multiple documents by their IDs and partition keys in a single request, which helps optimize performance and reduce the number of network round-trips compared to issuing multiple point reads. This is particularly useful for batch retrieval scenarios.
**Proposed API Shape:**
```rust
pub async fn read_many(
&self,
items: Vec<(&str, PartitionKey)>,
) -> Result, CosmosError>
where
T: DeserializeOwned;
```
- `items`: A vector of tuples containing the document ID (`&str`) and its partition key (`PartitionKey` type) for each item to read.
- Returns a vector of deserialized documents of type `T` upon success.
**Benefits:**
- Efficiency: Reduces the number of requests for batch retrievals.
- Convenience: Simplifies multiple document fetches for the user.
- Parity: Ensures the Rust SDK aligns with other Cosmos DB SDKs (such as .NET and Java) which already support ReadMany.
**References:**
- [ReadMany API - Azure Cosmos DB documentation](https://learn.microsoft.com/azure/cosmos-db/nosql/sdk-reference/read-many)
---
Let me know if any adjustments are needed to the proposed API or if additional implementation details are required.
Contributor guide
Research direction
Start with the linked Cosmos DB ReadMany API documentation and compare its requirements with the Rust SDK's existing Cosmos APIs. Done means exposing the proposed async read_many method, accepting document IDs with partition keys, and returning deserialized documents or CosmosError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100