RETURN
indicates that the statement result should be included in the query result.
All EQL statements begin with either DEFINE
or RETURN
.
RETURN
provides the key for accessing EQL results from the Dgraph query result. This is important when more than one statement is submitted with the query.
RETURN
syntax is:
RETURN <statementName> AS ...
Note that the statement name cannot be the same as the state name or as any other statement.RETURN Result AS SELECT COUNTDISTINCT(Color) AS Total FROM ProductState GROUP BY Size
WITH UNPAGED COUNT modifier
RETURN
clause can include an optional WITH UNPAGED COUNT
modifier that computes the unpaged (total) record count for the statement and returns the count as in a NumRecords
element in the results metadata. The syntax is:
RETURN <statementName> WITH UNPAGED COUNT AS ...
RETURN Results WITH UNPAGED COUNT AS SELECT WineType AS types, Flavors AS tastes FROM winestate
NumRecords="50"
It would then be the responsibility of the application to parse this element and print number for the application's UI. Note that NumRecords will still be 50 if you add, say PAGE(0,10)
to the statement.
WITH UNPAGED COUNT
can be used in a statement with a PAGE
clause.WITH UNPAGED COUNT
is ignored if used in a DEFINE
statement.