mattbishop / sql-jsonpath-js

JS implementation of the SQL/JSONPath dialect, from SQL2016.
MIT License
0 stars 0 forks source link

Support variables #11

Closed mattbishop closed 1 year ago

mattbishop commented 2 years ago

The spec allows for variables to be declared in a path statement, then populated in the functions. It is called the PASSING statement.

$.name ? (@ starts with $letter)

$letter is a variable in this statement.

The API should accept an optional variables object:

const sqlJsonPath = parse('$.name ? (@ starts with $letter)')
sqlJsonPath.exists({letter: 'm'})

Because of this feature, SQL JSONPath explicitly disallows JSON object keys starting with "$" characters. I wonder if they need to be addressed in array notation like $.person["$ref"]

mattbishop commented 1 year ago

Resolved in #20