in Source/Services/Tailwind.Traders.Stock.Api/src/main/java/Tailwind/Traders/Stock/Api/repositories/StockItemRepository.java [94:117]
private CosmosContainerProperties getTodoCollection() {
if (containerCache != null) {
return containerCache;
}
CosmosDatabase cosmosDatabase = cosmosClient.getDatabase(getTodoDatabase().getId());
Iterator<CosmosContainerProperties> collectionList = cosmosDatabase
.queryContainers(
"SELECT * FROM root r WHERE r.id='" + COLLECTION_ID + "'", null).iterator();
if (collectionList.hasNext()) {
containerCache = collectionList.next();
} else {
try {
CosmosContainerProperties cosmosContainerProperties = new CosmosContainerProperties(COLLECTION_ID, "/partition");
containerCache = cosmosDatabase
.createContainer(cosmosContainerProperties).getProperties();
} catch (CosmosException e) {
e.printStackTrace();
}
}
return containerCache;
}