Choose what comes back
Return objects with WHICH
Section titled “Return objects with WHICH”Place WHICH directly before every object type you want in the results.
WHICH Film is showing at WHICH Cinema at WHICH DateTimeThis selects Film, Cinema and DateTime. RETURN is optional.
For each selected object type, the default returned fields are those of the first-found uniqueness constraint. If no uniqueness constraint is found, NexQL returns the primary key. It does not mean “return every field”. The actual fields depend on your model.
Use A for a related object
Section titled “Use A for a related object”WHICH Film has A Session THAT has A Booking THAT is for (Person:'Simon')Film is selected. Session and Booking describe the relationship path; they are not selected with WHICH.
Name explicit fields with RETURN
Section titled “Name explicit fields with RETURN”Ask for the login names of people who booked Rocky:
WHICH Person made A Booking THAT is for A SessionTHAT is to watch (Film:'Rocky')RETURN Person.LoginNameThe explicit projection requests Person.LoginName. Use fields that exist in the mapped model; do not derive field names by guessing from the natural-language labels.
Count matching results
Section titled “Count matching results”WHICH Seat is in A Row in (Cinema:'Great Western Cinema')RETURN COUNT(*)This example counts matching seats. Aggregation explains grouped results.
Choose a projection deliberately
Section titled “Choose a projection deliberately”Use WHICH when you want the model’s default identifying fields. Use RETURN when a caller needs named columns or aggregates. For an agent tool with a fixed output contract, verify the actual result fields against the model.