Skip to content

Commit 36b36ee

Browse files
authored
Update README.md
1 parent 9bdaa94 commit 36b36ee

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ $records = Get-AllCosmosDbRecords ...
6767

6868
Queries the DB, returns the HTTP response. The records will be within the `Documents` property of the result.
6969

70-
Unfortunately, queries like aggregates, `TOP`, and `DISTINCT` are not supported - see the Cosmos DB docs [here](https://docs.microsoft.com/en-us/rest/api/cosmos-db/querying-cosmosdb-resources-using-the-rest-api#queries-that-cannot-be-served-by-gateway).
70+
This function is also used to perform aggregate queries (e.g. `count`, `TOP`, etc) - see examples below.
7171

7272
#### Examples
7373

@@ -94,6 +94,18 @@ $parameters = @{
9494
$records = Search-CosmosDbRecords -Query "SELECT * FROM c WHERE c.Id = @id and c.Number > @number" -Parameters $parameters ...
9595
| Get-CosmosDbRecordContent
9696
| % Documents
97+
98+
# Query TOP 10 records
99+
$records = Search-CosmosDbRecords -Query "SELECT TOP 10 * FROM c" ...
100+
| Get-CosmosDbRecordContent
101+
| % Documents
102+
103+
# Count records by a property (aggregate example)
104+
# Note: the results are within the Payload property of Documents and the aggregate value is inside the Item property of the aggregate value
105+
$records = Search-CosmosDbRecords -Query "SELECT count(1) as Cnt, c.Property FROM c GROUP BY c.Property" ...
106+
| Get-CosmosDbRecordContent
107+
| % { $_.Documents.Payload }
108+
| % { @{ Property = $_.Property; Count = $_.Cnt.Item} }
97109
```
98110

99111
#### Parameters

0 commit comments

Comments
 (0)