Skip to content

Commit 1daae53

Browse files
committed
JS SDK 4.1 updates
1 parent a6f7552 commit 1daae53

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

articles/cosmos-db/nosql/change-feed-modes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ During the preview, the following methods to read the change feed are available
120120

121121
| **Method to read change feed** | **.NET** | **Java** | **Python** | **Node.js** |
122122
| --- | --- | --- | --- | --- |
123-
| [Change feed pull model](change-feed-pull-model.md) | [>= 3.32.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.32.0-preview) | [>= 4.42.0](https://mvnrepository.com/artifact/com.azure/azure-cosmos/4.37.0) | No | No |
124-
| [Change feed processor](change-feed-processor.md) | [>= 3.40.0-preview.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.40.0-preview.0) | [>= 4.42.0](https://mvnrepository.com/artifact/com.azure/azure-cosmos/4.42.0) | No | No |
123+
| [Change feed pull model](change-feed-pull-model.md) | [>= 3.32.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.32.0-preview) | [>= 4.42.0](https://mvnrepository.com/artifact/com.azure/azure-cosmos/4.37.0) | No | [>= 4.1.0](https://www.npmjs.com/package/@azure/cosmos/v/4.1.0) |
124+
| [Change feed processor](change-feed-processor.md) | No | [>= 4.42.0](https://mvnrepository.com/artifact/com.azure/azure-cosmos/4.42.0) | No | No |
125125
| Azure Functions trigger | No | No | No | No |
126126

127127
> [!NOTE]

articles/cosmos-db/nosql/how-to-manage-indexing-policy.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,37 @@ const containerResponse = await client.database('database').container('container
601601
// retrieve the index transformation progress from the response headers
602602
const indexTransformationProgress = replaceResponse.headers['x-ms-documentdb-collection-index-transformation-progress'];
603603
```
604+
Add a composite index:
605+
606+
```javascript
607+
console.log("create container with composite indexes");
608+
const containerDefWithCompositeIndexes = {
609+
id: "containerWithCompositeIndexingPolicy",
610+
indexingPolicy: {
611+
automatic: true,
612+
indexingMode: IndexingMode.consistent,
613+
includedPaths: [
614+
{
615+
path: "/*",
616+
},
617+
],
618+
excludedPaths: [
619+
{
620+
path: '/"systemMetadata"/*',
621+
},
622+
],
623+
compositeIndexes: [
624+
[
625+
{ path: "/field", order: "ascending" },
626+
{ path: "/key", order: "ascending" },
627+
],
628+
],
629+
},
630+
};
631+
const containerWithCompositeIndexes = (
632+
await database.containers.create(containerDefWithCompositeIndexes)
633+
).container;
634+
```
604635

605636
### Use the Python SDK
606637

articles/cosmos-db/nosql/query/computed-properties.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,19 @@ containerProperties.setComputedProperties(modifiedComputedProperites);
176176
// Update the container with changes
177177
container.replace(containerProperties);
178178
```
179+
### [JavaScript](#tab/javascript)
180+
181+
```javascript
182+
const { resource: contDefinition } = await containerWithComputedProperty.read();
183+
const upperName = {
184+
name: "upperLastName", query: "SELECT VALUE UPPER(IS_DEFINED(c.lastName) ? c.lastName : c.parents[0].familyName) FROM c",
185+
};
186+
if (contDefinition) {
187+
// update computed properties contDefinition.computedProperties = [upperName]; // replace container definition with updated computed properties await containerWithComputedProperty.replace(contDefinition); console.log("Computed properties updated");
188+
} else {
189+
console.log("Container definition is undefined.");
190+
}
191+
```
179192

180193
### [Python](#tab/python)
181194
Updating computed properties on an existing container is not supported in Python SDK. You can only define computed properties when creating a new container. This is a work in progress currently.

0 commit comments

Comments
 (0)