Skip to main content
Module

x/pgsql_ast_parser/ast-visitor.ts>astVisitor

Yet another simple Postgres SQL parser
Go to Latest
function astVisitor
import { astVisitor } from "https://deno.land/x/pgsql_ast_parser@10.5.2/ast-visitor.ts";

Builds an AST visitor based on the default implementation, merged with the one you provide.

Example of visitor which counts references to a column 'foo':

let cnt = 0;
const visitor = astVisitor(v => ({
     ref: r => {
         if (r.name === 'foo') {
             cnt++;
         }
         v.super().ref(r);
     }
 }));

visitor.statement(myStatementToCount);
console.log(`${cnt} references to foo !`);

Parameters

visitorBuilder: (defaultImplem: IAstVisitor) => T