@@ -108,24 +108,36 @@ Container container = await client.GetDatabase("myDatabase").CreateContainerAsyn
108
108
### [ Java] ( #tab/java )
109
109
110
110
``` java
111
- CosmosContainerProperties containerProperties = new CosmosContainerProperties (" myContainer" , " /pk" );
112
- List<ComputedProperty > computedProperties = new ArrayList<> (List . of(new ComputedProperty (" cp_lowerName" , " SELECT VALUE LOWER(c.name) FROM c" )));
113
- containerProperties. setComputedProperties(computedProperties);
114
- client. getDatabase(" myDatabase" ). createContainer(containerProperties);
111
+ const { resource: contDefinition } = await containerWithComputedProperty. read();
112
+ const upperName = {
113
+ name: " upperLastName" ,
114
+ query:
115
+ " SELECT VALUE UPPER(IS_DEFINED(c.lastName) ? c.lastName : c.parents[0].familyName) FROM c" ,
116
+ };
117
+ if (contDefinition) {
118
+ // update computed properties
119
+ contDefinition. computedProperties = [upperName];
120
+ // replace container definition with updated computed properties
121
+ await containerWithComputedProperty. replace(contDefinition);
122
+ console. log(" Computed properties updated" );
123
+ } else {
124
+ console. log(" Container definition is undefined." );
125
+ }
115
126
```
116
127
117
128
### [ JavaScript] ( #tab/javascript )
118
129
119
130
``` javascript
120
- const { resource: contDefinition } = await containerWithComputedProperty .read ();
121
- const upperName = {
122
- name: " upperLastName" , query: " SELECT VALUE UPPER(IS_DEFINED(c.lastName) ? c.lastName : c.parents[0].familyName) FROM c" ,
131
+ const lowerName = {
132
+ name: " lowerLastName" ,
133
+ query:
134
+ " SELECT VALUE LOWER(IS_DEFINED(c.lastName) ? c.lastName : c.parents[0].familyName) FROM c" ,
123
135
};
124
- if (contDefinition) {
125
- // update computed properties contDefinition.computedProperties = [upperName]; // replace container definition with updated computed properties await containerWithComputedProperty.replace(contDefinition); console.log("Computed properties updated");
126
- } else {
127
- console . log ( " Container definition is undefined. " );
128
- }
136
+
137
+ const { container : containerWithComputedProperty } = await database . containers . createIfNotExists ({
138
+ id : containerId,
139
+ computedProperties : [lowerName],
140
+ });
129
141
```
130
142
131
143
### [ Python] ( #tab/python )
0 commit comments