erondem
erondem

Reputation: 592

How to query couchbase with multiple values using spring-data-couchbase

Hi I have an endpoint like /findBy and it can take several query params similar like ;

findBy?color="blue"&size="big"&city="ny"&country="usa"

How can I have such query in repository layer using spring-data-couchbase. Normally if it would something like findByCity or findByColor only I would have such methods in my repository

@Repository
public interface HouseRepository  extends CouchbaseRepository<House, String> {

    House findByColor(String Color);
    House findByCity(String City);
}

but in this case I might not get all the parameter values. I want to query whatever values I have. Same findBy should return the values in these cases:

findBy?country="usa"
findBy?city="ny"&country="usa"
findBy?color="blue"&size="big"

Can such thing be done using spring data couchbase without writing custom sql queries?

Upvotes: 1

Views: 664

Answers (1)

İsmail Y.
İsmail Y.

Reputation: 3965

You can use Querydsl Extension.

Querydsl is a framework that enables the construction of statically typed SQL-like queries through its fluent API.

You have QueryDSL integration, you can derive queries from the attributes contained in a Request query string.

Please see these links for more information:

Upvotes: 2

Related Questions