0

I am trying to create(using spring native query) the findAllId for the reactive repository spring data cosmo DB. Since for the ReactiveCosmosRepository is not implemented.

@Query(value = " SELECT *\n" +
        " FROM   container_name km\n" +
        " WHERE  km.id IN (@ids) \n" +
        " ORDER  BY km.createdDate DESC ")
Flux<ContainerData> findAllById(@Param("ids") String[] ids);

or even

@Query(value = " SELECT *\n" +
        " FROM   container_name km\n" +
        " WHERE  km.id IN (@ids) \n" +
        " ORDER  BY km.createdDate DESC ")
Flux<ContainerData> findAllById(@Param("ids") Iterable<String> ids);

but it is not retrieving any results, and it is not throwing any exception either.

So the question is, how to use IN operator with spring data native query in cosmos db and collection or array out of the box without having to do a workaround.

1
  • Did you try array_contains ? Commented May 11, 2021 at 23:46

1 Answer 1

2

You should use array_contains

@Query(value = " SELECT *\n" +
        " FROM   container_name km\n" +
        " WHERE  array_contains(@ids, km.id, true) \n" +
        " ORDER  BY km.createdDate DESC ")
Flux<ContainerData> findAllById(@Param("ids") Iterable<String> ids);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.