Skip to content

Commit

Permalink
Fixed computed properties code snippet (#40431)
Browse files Browse the repository at this point in the history
* Fixed computed properties code snippet

* Fixed subscribe

* Fixed code snippet usage
  • Loading branch information
kushagraThapar authored May 31, 2024
1 parent 0bb9aaa commit 99e4482
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* )
* );
* containerProperties.setComputedProperties(computedProperties);
* database.createContainer(containerProperties);
* database.createContainer(containerProperties).subscribe();
* </pre>
* <!-- end com.azure.cosmos.computedProperty.createContainer -->
*
Expand All @@ -30,8 +30,9 @@
* new ComputedProperty&#40;&quot;upperName&quot;, &quot;SELECT VALUE UPPER&#40;c.name&#41; FROM c&quot;&#41;
* &#41;
* &#41;;
* containerProperties.setComputedProperties&#40;computedProperties&#41;;
* container = database.getContainer&#40;containerName&#41;;
* container.replace&#40;containerProperties&#41;;
* container.replace&#40;containerProperties&#41;.subscribe&#40;&#41;;
* </pre>
* <!-- end com.azure.cosmos.computedProperty.replaceContainer -->
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void createContainerWithComputedProperties() {
)
);
containerProperties.setComputedProperties(computedProperties);
database.createContainer(containerProperties);
database.createContainer(containerProperties).subscribe();
// END: com.azure.cosmos.computedProperty.createContainer
}

Expand All @@ -48,21 +48,22 @@ public void replaceContainerWithComputedProperties() {
new ComputedProperty("upperName", "SELECT VALUE UPPER(c.name) FROM c")
)
);
containerProperties.setComputedProperties(computedProperties);
container = database.getContainer(containerName);
container.replace(containerProperties);
container.replace(containerProperties).subscribe();
// END: com.azure.cosmos.computedProperty.replaceContainer
}

public void replaceContainerWithExistingComputedProperties() {
// BEGIN: com.azure.cosmos.computedProperty.replaceContainer.existingProperties
container = database.getContainer(containerName);

CosmosContainerProperties modifiedProperites = container.read().block().getProperties();
Collection<ComputedProperty> modifiedComputedProperites = modifiedProperites.getComputedProperties();
modifiedComputedProperites.add(new ComputedProperty("upperName", "SELECT VALUE UPPER(c.firstName) FROM c"));
modifiedProperites.setComputedProperties(modifiedComputedProperites);
CosmosContainerProperties modifiedProperties = container.read().block().getProperties();
Collection<ComputedProperty> modifiedComputedProperties = modifiedProperties.getComputedProperties();
modifiedComputedProperties.add(new ComputedProperty("upperName", "SELECT VALUE UPPER(c.firstName) FROM c"));
modifiedProperties.setComputedProperties(modifiedComputedProperties);

container.replace(modifiedProperites);
container.replace(modifiedProperties).subscribe();
// END: com.azure.cosmos.computedProperty.replaceContainer.existingProperties
}

Expand Down

0 comments on commit 99e4482

Please sign in to comment.