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

fossil

v0.8.1

Published

Active-Record style storage system for Node JS

Readme

fossil

NPM version Build Status

ActiveRecord-style persistence system for Node JS projects. Fossil provides a Model base class that may be used to create your own Model types. Fossil's Model class provides ActiveRecord functions such as create, save, find and where. Fossil will intelligently link Model types to their corresponding database table using an ActiveRecord-style naming convention, however you can override both default table and property name mappings if needed.

Fossil also provides an inbuilt validation system that's invoked when an attempt is made to save a Model object. Failed validation will result in an exception being thrown.

How to Install

npm install fossil --save

How to Use

Fossil uses knex to connect to your database. When initializing fossil, you'll need to provide a knex-style configuration object. Fossil query methods return promises which resolve to the desired results or reject if an error occurs.

Example


var Model = require( "fossil" )( {
    client: 'mysql',
    connection: {
        host     : '127.0.0.1',
        user     : 'your_database_user',
        password : 'your_database_password',
        database : 'myapp_test'
    }
} );

class MyModelClass extends Model
{}

MyModelClass.validations = {    id: [ "int", { minimum: 1 } ],
                                name: [ "string", function( v ) { return v[0] == "."; }, { length: { maximum: 50 } ] };

let first   = MyModelClass.first.then( ( obj ) => // do something with retrieved object );
let second  = MyModelClass.find( { id: 2 } ).then( ( obj ) => // do something with retrieved object );
let all     = MyModelClass.all.then( ( objects ) => // do something with retrieved objects );

let saved   = new MyModelClass;
saved.id    = 0;


saved.save.then( ( obj ) => {
    console.log( "We won't reach this point" );
} ).error( ( failures ) => {
    console.log( "Save will fail due to invalid id field value" );
} );

The first time any model is accessed, fossil will read the database and generate a map of tables, columns and column types. This map is used to generate model objects when queries are executed, so you don't need to defined properties on your models; these will be populated at query time