Skip to content

Commit f90b940

Browse files
update readme (Azure#25830)
### Packages impacted by this PR @azure/comsos ### Issues associated with this PR ### Describe the problem that is addressed by this PR Updated README documentation for non-streamable cross-partition queries ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ Change in readme file ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) --------- Co-authored-by: Manik Khandelwal <mkhandelwal@microsoft.com>
1 parent 3c6ce1d commit f90b940

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

sdk/cosmosdb/cosmos/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Currently the features below are **not supported**. For alternatives options, ch
278278

279279
* Queries with COUNT from a DISTINCT subquery​
280280
* Direct TCP Mode access​
281-
* Continuation token for cross partitions queries
281+
* Aggregate cross-partition queries, like sorting, counting, and distinct, don't support continuation tokens. Streamable queries, like SELECT \* FROM <table> WHERE <condition>, support continuation tokens. See the "Workaround" section for executing non-streamable queries without a continuation token.
282282
* Change Feed: Processor
283283
* Change Feed: Read multiple partitions key values
284284
* Change Feed: Read specific time
@@ -299,6 +299,28 @@ You can achieve cross partition queries with continuation token support by using
299299
[Side car pattern](https://github.com/Azure-Samples/Cosmosdb-query-sidecar).
300300
This pattern can also enable applications to be composed of heterogeneous components and technologies.
301301

302+
### Executing non-stremable cross-partition query
303+
304+
To execute non-streamable queries without the use of continuation tokens, you can create a query iterator with the required query specification and options. The following sample code demonstrates how to use a query iterator to fetch all results without the need for a continuation token:
305+
306+
```javascript
307+
const querySpec = {
308+
query: "SELECT * FROM c WHERE c.status = @status",
309+
parameters: [{ name: "@status", value: "active" }],
310+
};
311+
const queryOptions = {
312+
maxItemCount: 10, // maximum number of items to return per page
313+
enableCrossPartitionQuery: true,
314+
};
315+
const querIterator = await container.items.query(querySpec, queryOptions);
316+
while (querIterator.hasMoreResults()) {
317+
const { resources: result } = await querIterator.fetchNext();
318+
//Do something with result
319+
}
320+
```
321+
322+
This approach can also be used for streamable queries.
323+
302324
### Control Plane operations
303325
Typically, you can use [Azure Portal](https://portal.azure.com/), [Azure Cosmos DB Resource Provider REST API](https://docs.microsoft.com/rest/api/cosmos-db-resource-provider), [Azure CLI](https://docs.microsoft.com/cli/azure/azure-cli-reference-for-cosmos-db) or [PowerShell](https://docs.microsoft.com/azure/cosmos-db/manage-with-powershell) for the control plane unsupported limitations.
304326

0 commit comments

Comments
 (0)