@queryfiit/pg-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

@queryfiit/pg-parser

The real PostgreSQL parser, exposed for nodejs.

This is based on the output of libpg_query. This wraps the static library output and links it into a node module for use in js.

All credit for the hard problems goes to Lukas Fittl.

Installation

npm install @queryfiit/pg-parser

Documentation

query.parseQuery(sql)/parseQuerySync

Parses the sql and returns a Promise for the parse tree (or returns the parse tree directly in the sync version). May reject with/throw a parse error.

The return value is an array, as multiple queries may be provided in a single string (semicolon-delimited, as Postgres expects).

query.parsePlPgSQL(funcsSql)/query.parsePlPgSQLSync(funcsSql)

Parses the contents of a PL/PGSql function, from a CREATE FUNCTION declaration, and returns a Promise for the parse tree (or returns the parse tree directly in the sync version). May reject with/throw a parse error.

Example

const parser = require('@sqlutils/parse');
parser.parseQuery('select 1').then(console.log);

Related

Package Sidebar

Install

npm i @queryfiit/pg-parser

Weekly Downloads

0

Version

1.0.4

License

BSD-3-Clause

Unpacked Size

16.3 MB

Total Files

61

Last publish

Collaborators

  • matus.kislan