Skip to content

Documentation / @andrew_l/search-query-language / parseQuery

Function: parseQuery()

parseQuery(value): NodeProgram

Parses a query string into a NodeProgram representation.

Parameters

value: string

The query string to be parsed.

Returns

NodeProgram

  • The parsed representation of the query.

Example

ts
const program = parseQuery('age > 30');
console.log(program);
// {
//   type: 'program',
//   body: [
//     {
//       type: 'binary-expression',
//       operator: '>',
//       left: { type: 'identifier', name: 'age' },
//       right: { type: 'literal', value: 30 }
//     }
//   ]
// }