Hi,¨
For some reason I need to use java code to query content, how can I f.ex translate this JS code into Java?
var result = contentLib.query({
start: 0,
count: 10000,
sort: “pickupOrDeliveryTime ASC”,
query: “data.orderStatus = '” + orderStatus + “’”,
branch: “master”,
contentTypes: [
app.name + “:order”
]
});
final String orderStatus = "fisk";
final QueryExpr queryExpr = QueryParser.parse( "data.orderStatus = '" + orderStatus + "' order by pickupOrDeliveryTime ASC" );
final ContentQuery query = ContentQuery.create().
queryExpr( queryExpr ).
size( 10000 ).
from( 0 ).
build();
Then, create a context with the user / repo / branch you should query, and run the query:
final FindContentIdsByQueryResult result = ContextBuilder.from( ContextAccessor.current() ).
branch( "master" ).
build().
callWith( () -> contentService.find( query ) );
There exists a task for making the java query expression api more fluent, but we havent come around to that yet, but it will be improved pretty soon I hope.