ComputedProperty Class

  • java.lang.Object
    • com.azure.cosmos.models.ComputedProperty

public final class ComputedProperty

Represents a computed property definition for a Cosmos DB container. Below is an example of how to use ComputedProperty in the context of creating a container.

List<ComputedProperty> computedProperties = new ArrayList<>(
         Arrays.asList(
                 new ComputedProperty("lowerName", "SELECT VALUE LOWER(c.name) FROM c")
         )
 );
 containerProperties.setComputedProperties(computedProperties);
 database.createContainer(containerProperties);

Below is an example of how to use ComputedProperty in the context of replacing a container.

CosmosContainerProperties containerProperties = getCollectionDefinition(containerName);
 List<ComputedProperty> computedProperties = new ArrayList<>(
         Arrays.asList(
                 new ComputedProperty("upperName", "SELECT VALUE UPPER(c.name) FROM c")
         )
 );
 container = database.getContainer(containerName);
 container.replace(containerProperties);

Constructor Summary

Constructor Description
ComputedProperty(String name, String query)

Instantiates a new Computed properties with name and query.

Method Summary

Modifier and Type Method and Description
String getName()

Gets the name of the computed property.

String getQuery()

Gets the query used to evaluate the value for the computed property.

Methods inherited from java.lang.Object

Constructor Details

ComputedProperty

public ComputedProperty(String name, String query)

Instantiates a new Computed properties with name and query.

Parameters:

name - the name of the computed property.
query - the query used to evaluate the value for the computed property.

Method Details

getName

public String getName()

Gets the name of the computed property.

Returns:

the name of the computed property.

getQuery

public String getQuery()

Gets the query used to evaluate the value for the computed property.

Returns:

the query for the computed property.

Applies to