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 🙏

© 2026 – Pkg Stats / Ryan Hefner

lightweight-pg-orm

v0.5.9

Published

Lightweight node package that helps you manage your PostgreSQL database.

Readme

lightweight-pg-orm

lightweight-pg-orm is built on top of pg, Node, and Express to help you easily create CRUD functions on your PostgreSQL database.

Installation

Use npm to install.

npm install lightweight-pg-orm

Usage

This is best used on your Express routes.

const express = require("express");
const Model = require("lightweight-pg-orm");

const app = express();

const company = new Model("companies", "id", ["id",
  "name",
  "num_employees",
  "description",
  "logo_url"]
);

app.get("/", async function (req, res, next) {
  try {
    const results = await company.findAll(req.query);
    return res.status(200).json({ "companies": results });
  } catch (error) {
    return next(error);
  };
});

App.js must include a global variable for the root directory. Example below

global.__basedir = __dirname;

const express = require('express');
const app = express();

/** Routes */
app.get('/', function (req, res, next) {
  return res.status(200).json({
    'status': 200,
    'item': "This is the homepage, nothing to see here.",
  })
});

/** 404 Error Handler */
app.use(function (req, res, next) {
  const error = new ExpressError('Page Not Found', 404);
  return next(error);
});

/** Error Handler */
app.use(function (err, req, res, next) {
  res.status = err.status || 500;

  return res.json({
    status: res.status,
    message: err.message
  });
});

module.exports = app;

BUGS

SQL-Injections: Currently, we are handling SQL-injections on external requests but they are not handled when you create a model/table class.

Versions

(live) 0.5.1 - First working version

(TBD) 1.0.0 - Will better organize the code and handle SQL-injections when creating the classes.

Methods

Class Methods (Use these):

-> get: retrieves single item from database.

-> findAll: retrieves all items from database or items matching query.

-> create: Creates a new item in the database.

-> update: Updates item in the database.

-> delete: Deletes item in the database.

Helper functions:

-> WhereExpressions: creates where expressions depending on query passed.

-> createquery: creates SQL queries.

-> partialupdatequery: creates queries for update

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Errors and bugs

If something is not behaving intuitively, it is a bug and should be reported. Report it here by creating an issue: https://github.com/Leomedina/lightweight-pg-orm/issues.

Help me fix the problem as quickly as possible by following Mozilla's guidelines for reporting bugs.

License

MIT