RutledgePaulV / q-builders

Type safe database agnostic query builders.
MIT License
55 stars 26 forks source link

Is it possible to build queries for nested fields #22

Closed ffray closed 6 years ago

ffray commented 6 years ago

Hi,

I've got a Domain Model using some nested structures and would like to create a QBuilder for this.

@Data
public class Person {
  private String name;
  private Address address;
}

@Data
public class Address {
  private String street;
  private String zipCode;
  private String city;
}

I'd like to generate such an RSQL for this structure: 'name==John Doe;address.street==Main St;address.city==Anytown'

Could you give me some guidance if this is possible?

Best regards,

Florian

RutledgePaulV commented 6 years ago

Hi, yes this is possible. Just use a dot as a delimiter and it should be handled by all the existing visitors.

new YourQueryModel().string("address.street").eq("Main St");

You can create an AddressQueryModel and a PersonQueryModel too and add a method to your PersonQueryModel that proxies AddressQueryModel and modifies the paths to include the "address." prefix.