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

@robinsax/sago

v0.0.11

Published

A mini-ORM for node & PostgreSQL

Readme

sago

CircleCI Coverage Status

sago is pre-stable, use with caution.

sago is a mini-ORM for node & PostgreSQL. It's intended for web application development.

At a glance

  • Tiny and opinionated, like Angela from The Office.
  • Zero needless dependencies; just node-postgres.
  • Attactive, low character count usage code.
  • Strictly typed and validated model attributes.
  • Explicit relationship management.
  • Rarely and predictably async.
  • Easy serialization to, and deserialization from, JSON (with useful validation errors).
const sago = require('sago');

const { Model, session, collection } = sago('demo_db');

//  Model definitions.
@collection('recipes') // or database.register(Recipe).
class Recipe extends Model {
    schema = {
        id: ['uuid', {pk: true}],
        name: ['string', {length: 40}]
    };

    get ingredients() { return this.manyRelation(Ingredient); }
}

@collection('ingredients')
class Ingredient extends Model {
    schema = {
        id: ['uuid', {pk: true}],
        recipe_id: ['uuid', {fk: 'recipes.id'}],
        name: ['string', {length: 40}],
        quantity: 'int'
    }

    get recipe() { return this.oneRelation(Recipe); }
}

//  Usage.
(async () => {
    const sess = session();

    //  Easy to use models? No problem.
    const breakfast = new Recipe({name: 'bacon and eggs'});
    
    //  Explicit relationship management and different coupling styles.
    const bacon = new Ingredient({name: 'bacon', quantity: 4});
    bacon.recipe.set(breakfast); // OR breakfast.ingredients.push(bacon);
    const eggs = new Ingredient({name: 'eggs', quantity: 2, recipe: breakfast});
    
    //  All the relationship management you deserve.
    breakfast.ingredients.get(); // [eggs, bacon]

    //  Related models stored automatically.
    await sess.add(breakfast).commit();

    //  Relationship construction always happens in-database.
    eggs.recipe_id == breakfast.id; // true

    breakfast.name = 3; // Throws an AttributeTypeError.
    breakfast.name = new Array(41).fill('x').join(''); // Throws an AttributeValueError.

    const untrustedInput = {name: new Date(), id: 1};
    //  Batch operations from untrusted input. These throw friendly aggregated errors.
    breakfast.update(untrustedInput);
    new Recipe(untrustedInput);

    //  Deep serialization is easy.
    breakfast.serialize({include: ['ingredients']});

    //  Automatic attribute update management, of course.
    breakfast.name = 'simple bacon and eggs';
    //  ...and it's all transactional.
    await sess.commit();
})();

Install and testing

npm i @robinsax/sago --save-dev
npm test