diff --git a/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/CosmosConfiguration.java b/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/CosmosConfiguration.java index 38029d6..7e1ff34 100644 --- a/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/CosmosConfiguration.java +++ b/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/CosmosConfiguration.java @@ -11,17 +11,15 @@ import com.azure.spring.data.cosmos.config.CosmosConfig; import com.azure.spring.data.cosmos.repository.config.EnableCosmosRepositories; -// @Configuration @EnableCosmosRepositories public class CosmosConfiguration extends AbstractCosmosConfiguration { -// @Value("#{environment.AZURE_COSMOS_DB_NOSQL_ENDPOINT}") private String uri; @Bean - public CosmosClientBuilder getCosmosClientBuilder() { + public CosmosClientBuilder getCosmosClientBuilder() { return new CosmosClientBuilder() .endpoint("") .key(""); @@ -34,10 +32,8 @@ public CosmosConfig cosmosConfig() { .build(); } - // @Override protected String getDatabaseName() { return "cosmicworks"; } - // } diff --git a/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/Item.java b/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/Item.java index f322e9c..85cb241 100644 --- a/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/Item.java +++ b/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/Item.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -// @Container(containerName = "products", autoCreateContainer = false) public class Item { private String id; @@ -15,7 +14,6 @@ public class Item { @PartitionKey private String category; - // public Item() { } diff --git a/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/ItemRepository.java b/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/ItemRepository.java index 0895d97..2b0af39 100644 --- a/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/ItemRepository.java +++ b/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/ItemRepository.java @@ -8,10 +8,8 @@ import com.azure.spring.data.cosmos.repository.CosmosRepository; import com.azure.spring.data.cosmos.repository.Query; -// @Repository public interface ItemRepository extends CosmosRepository { @Query("SELECT * FROM products p WHERE p.category = @category") List getItemsByCategory(@Param("category") String category); } -// diff --git a/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/StartController.java b/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/StartController.java index 6a43b40..e8b90f4 100644 --- a/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/StartController.java +++ b/src/main/java/com/microsoft/learn/azure/cosmosdb/nosql/quickstart/StartController.java @@ -37,7 +37,6 @@ public void start() throws Exception { this.sendMessage(String.format("Get container:\t%s", "products")); { - // Item item = new Item( "70b63682-b93a-4c77-aad2-65501347265f", "gear-surf-surfboards", @@ -46,7 +45,7 @@ public void start() throws Exception { false ); Item created_item = repository.save(item); - // + this.sendMessage(String.format("Upserted item:\t%s", created_item)); } @@ -62,24 +61,22 @@ public void start() throws Exception { this.sendMessage(String.format("Upserted item:\t%s", created_item)); } - // PartitionKey partitionKey = new PartitionKey("gear-surf-surfboards"); Optional existing_item = repository.findById("70b63682-b93a-4c77-aad2-65501347265f", partitionKey); if (existing_item.isPresent()) { // Do something } - // + existing_item.ifPresent(i -> { this.sendMessage(String.format("Read item id:\t%s", i.getId())); this.sendMessage(String.format("Read item:\t%s", i)); }); - // List items = repository.getItemsByCategory("gear-surf-surfboards"); for (Item item : items) { // Do something } - // + this.sendMessage("Found items:"); try { ObjectWriter writer = new ObjectMapper().writer().withDefaultPrettyPrinter();