Skip to content

Comments

spring custom query with cosmos template#10

Open
TheovanKraay wants to merge 1 commit intoAzure-Samples:mainfrom
TheovanKraay:spring-custom-query
Open

spring custom query with cosmos template#10
TheovanKraay wants to merge 1 commit intoAzure-Samples:mainfrom
TheovanKraay:spring-custom-query

Conversation

@TheovanKraay
Copy link
Contributor

Purpose

Show example of how to run custom queries using the raw Cosmos DB SQL API query syntax with CosmosTemplate

  • ...

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[x] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

Copy link
Contributor

@kushagraThapar kushagraThapar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting some changes!
I am curious to know the use case for executing this simple custom query through cosmosTemplate. This query can be easily executed through @Query annotation. There is no value in autowiring CosmosTemplate if not needed. It might add additional complexity.

One use case that I have constantly seen and asked for is how to construct query through Criteria object in spring-data-cosmos, which is also a pretty generic thing to do in spring-data. Criteria class should be able to define what all a customer needs for a query. And then let spring-data-cosmos SDK execute that criteria in a query form.

Some examples are here -

https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java#L449

https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java#L495

https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java#L610

https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java#L640

Additional PR for some more details on criteria development and usage - Azure/azure-sdk-for-java#30379

@TheovanKraay
Copy link
Contributor Author

TheovanKraay commented Oct 31, 2022

Fair point, I will come up with a query that cannot be executed using @query or Criteria. Point is, customers want to be able to just inject the SQL API query rather than follow the Criteria or @query pattern in some cases (because it doesn't support what they want, or even because it is cumbersome).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants