I have a custom component which should output all NewsDocument (documenttype) which have specific Category (linked documenttype). I will pass category_id as a parameter.
I found the following query constraint in documentation but it only works if Category is a Compound type. In my case Category is Document Type and linked to NewsDocument.
public void doBeforeRender() {
// …
HstQuery newsQuery = HstQueryBuilder.create(scope)
.ofTypes(NewsDocument.class)
.where(constraint(“mysite:category/@mysite:category_id”).contains(‘sport’))
.build();
HstQueryResult result = newsQuery.execute();
// …
}