Here’s an example of parsing your query, and printing out the AST to the console:
eben$ node
Welcome to Node.js v12.16.1.
Type ".help" for more information.
> var parser = require("./n1ql").parser;
undefined
> console.log(JSON.stringify(parser.parse("SELECT MAX(age) AS MaximumAge FROM Users;"),null,2));
[
{
"type": "Select",
"ops": {
"select_terms": {
"type": "Subselect",
"ops": {
"with_expr": null,
"from": {
"type": "KeyspaceTerm",
"ops": {
"namespace": "",
"keyspace": "Users",
"as_alias": ""
}
},
"let": null,
"where": null,
"group": null,
"select": {
"type": "Projection",
"ops": {
"distinct": false,
"projects": [
{
"type": "ResultTerm",
"ops": {
"expression": {
"type": "Function",
"ops": {
"fname": "MAX",
"param_expr": [
{
"type": "Identifier",
"ops": {
"identifier": "age"
}
}
]
}
},
"star": false,
"as_alias": "MaximumAge"
}
}
]
}
}
}
},
"order_by": null,
"offset": null,
"limit": null
},
"pathsUsed": [
"Users",
[
"Users"
]
]
}
]
undefined
>