A select operation is defined by a SELECT clause. The select clause value describes the structure of the return JSON. Specific keywords or symbols define what value will be included. The select, with replaced keywords must for a valid JSON element. The keywords are $REF, $, and $ROOT. $ will always be a valid JSON element as will the $ROOT.
The $ keywords are expanded as follows.
A WHERE clause is required to specify what will be returned. A WHERE value thats either a number or a string is treated as a reference number for a specific node and will return either a single match or none. A WHERE clause that is an expression will return all expression matches except those filter by any FILTER expression.
Additional options exist to modify the return list from a SELECT. Those options are LIMIT, SORT, and CURSOR.
The LIMIT clause limits the number of returned items to the values specified.
The SORT clause sorts the out returned items according to the provided Path.
The CURSOR clause is used for paging. The arguments are the cursor ID and a starting position in a result set.
The return from an SELECT is a JSON Object. The contents of the result Object will be different depending on the success or failure of the evaluation. In all cases a code member will be present. A code value of zero indicates success. Any other value indicates an error.
On success the JSON object result will include a results member that is an array of the expanded JSON in the SELECT clause for each matching record.
If an error occurs during statement processing or the statement is not valid the JSON object result will include a error member describing the error.