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

postgresupdater

v1.0.16

Published

automatic database updates for pg

Downloads

24

Readme

PostgresUpdater

installation

npm i --save postgresupdater

usage

const pg = require('postgresupdater')(host, port, user, password, database);

pg.waitForInit().then(async () => {
  console.log(pg.getVersion()); //prints out the current database version

  const data = await pg.query('SELECT * FROM "SomeTable" WHERE ID = $1', [10]); // get entry with id 10

  pg.stop(); // end database connection
});

constructor arguments:

postgresupdater(
  host,     //host to connect to
  port,     //port of the postgres server
  user,     //username
  password, //password
  database, //database to connect to
  schema,   //schema to use (default 'public')
  recreate  //if true, deletes current schema, creates an empty one and runs all update scripts on that empty schema (default: false)
)

updates

every time the module gets initialized, it searches for updates in ./updates/ in the current working directory. update files have to be named xxxx.sql with the name consisting of only numbers. all updates will be executed in ascending order. note that updates with leading 0 will not be executed since this module uses an incrementing number to find updates.

0.sql

-- first update, initializing tables
CREATE TABLE "SomeTable" (
  "ID" SERIAL,
  "Value" CHARACTER(3) NOT NULL
);

1.sql

-- insert some data
INSERT INTO "SomeTable" ("Value") VALUES ('asd');
INSERT INTO "SomeTable" ("Value") VALUES ('fgh');
INSERT INTO "SomeTable" ("Value") VALUES ('jkl');

After starting this example, the database will have one table with 3 rows of data by default