npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pg-view-grabber

v1.2.0

Published

Grab view information from a Postgres database.

Downloads

5

Readme

PG View Grabber

Grab view information from a Postgres database.

Use

Install the module with:

npm install pg-view-grabber --save

Configuration

You’ll need to pass in Postgres connection info that will be passed to pg’s Client constructor. This can either be a connection string (Ex: postgres://username:password@localhost/database) or an object:

var myConfig = {
    database: 'postgres',
    host: 'localhost',
    password: '',
    port: 5432,
    user: 'root',
};

Then, pass it in like so:

var pgViewGrabber = require('pg-view-grabber');

pgViewGrabber.config(myConfig);

You’re ready to get started!

API

These methods hang off the main pg-view-grabber module:

pgViewGrabber.config(clientConfig)
  • Arguments:
    • clientConfig (object or string): database configuration passed to pg’s Client
  • Returns:
    • undefined
pgViewGrabber.fromTable(tableName)
  • Arguments:
    • tableName (string): name of table for which to find dependent views
  • Returns:
    • Promise that resolves to an array of ‘view data’ objects with the following keys:
      • viewData.definition: the view's SQL definition
      • viewData.permissions: the view's owner and permissions SQL
      • viewData.schema: the view's schema name
      • viewData.viewName: the view name itself
pgViewGrabber.fromView(viewName)
  • Arguments:
    • viewName (string): name of view for which to find dependent views
  • Returns:
    • Promise that resolves to an array of 'view data' objects

Liquibase Migration Methods

All Liquibase methods have the same argument object:

  • Arguments:
    • options (object):
      • options.name (string): Name of table or view
      • options.author (optional string): “author” for the migration file
      • options.formatFilename (optional function): a function responsible for formatting each migration file's filename. It’s passed a filenameOptions object with the following keys:
        • filenameOptions.author
        • filenameOptions.id
        • filenameOptions.schema
        • filenameOptions.viewName
      • options.id (optional string or number): changeset “id” for the migration file
pgViewGrabber.getTableMigration(options)
  • Returns:
    • Promise that resolves to an array of Liquibase migration templates
pgViewGrabber.getViewMigration(options)
  • Returns:
    • Promise that resolves to an array of Liquibase migration templates
pgViewGrabber.saveTableMigration(options)
  • Returns:
    • Promise that resolves to an array of empty values when all migration files are written
pgViewGrabber.saveViewMigration(options)
  • Returns:
    • Promise that resolves to an array of empty values when all migration files are written

Testing

Testing assumes you’re on the MRN VPN and you have a valid database map in /coins/coins_auth/conn/dbmap.json. Run tests with npm test. Run linting with npm run lint.