question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Need a way to inject partitionKey for CosmosContainer.queryItems method

See original GitHub issue

Description I’m trying to use the method CosmosContainer.queryItems to query db. However, I am not able to set partition key in CosmosQueryRequestOptions, as the setters is of default type. Also, ModelBridgeInternal doesn’t have a means to equip CosmosQueryRequestOptions with partition key.

Expected behaviour Need a way to inject partition key in CosmosContainer.queryItems method

SDK version:

  • 4.2.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kushagraThaparcommented, Jul 22, 2020

Yes, you should be able to call CosmosItemResponse#getItem() API - and that will return the saved response object in the same Object model that you provided it with initially. Make sure you enable this property contentResponseOnWriteEnabled in CosmosClientBuilder because SDK doesn’t return full responses by default for write operations.

Read the docs and it should be clear on how and when to use it : https://github.com/Azure/azure-sdk-for-java/blob/azure-cosmos_4.2.0/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java#L362

0reactions
zahiritprocommented, Jul 22, 2020

@kushagraThapar Probably I had checked the wrong version. I can see the setter public in V4.2. Thank you. Will close the issue.

Also, I use ModelsBridgeInternal.getInternalObjectNode(CosmosItemResponse) to retrieve id and partition key from CosmosItemResponse… Is it discouraged to use ModelsBridgeInternal for this task…Is there an alternative ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Container.GetItemQueryIterator Method - Microsoft Learn
This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It...
Read more >
Can we use cosmosContainer.queryItems() method to execute ...
I have a Java method in my code, in which I am using following line of code to fetch any data from azure...
Read more >
Azure Cosmos Database — CRUD using Azure Cosmos SDK
Let's check how many items were inserted in the Cosmos Container. The below query shows how many items we have per partition.
Read more >
Index (Azure SDK for Java Reference Documentation) - NET
Specifies the options associated with change feed methods (enumeration ... Encapsulates error related details in the Azure Cosmos DB database service.
Read more >
Azure Cosmos DB support for Java source code
Insert. Methods supported for insertv - v2. com.microsoft.azure.documentdb. ... Links are created for transaction and function point needs: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found