1.1.1-v12 • Published 4 years ago

@pyramation/pg-query-native v1.1.1-v12

Weekly downloads
-
License
BSD
Repository
github
Last release
4 years ago

pg-query-native Build Status

The real PostgreSQL parser 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.

How to re-buid

git clone -b 12-latest-develop git://github.com/lfittl/libpg_query
cd libpg_query
make

Then get the .a file and drop it in the folder in this repo.

Installation

npm install pg-query-native-latest

Documentation

query.parse(query)

Parses the query and returns the parse tree.

Parameters

parametertypedescription
queryStringSQL query

Returns an object in the format:

{ query: <query|Object>,
  error: { message: <message|String>,
           fileName: <fileName|String>,
           lineNumber: <line|Number>,
           cursorPosition: <cursor|Number> }

Example

var parse = require('pg-query-native').parse;

console.log(parse('select 1').query);

Related