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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ee-bookshelf-schema

v0.1.10

Published

simple schema definitoion for bookshelf.js

Readme

ee-bookshelf-schema

DEPRECATED: we're now using ee-orm instead of this module & bookshelf. This module will not be maintained anymore.

simple schema definitoion for bookshelf.js

installation

npm install 

you may need to install the libpq-dev library

sudo apt-get install libpq-dev

usage

For the detailed usage see the bookshelf & knex docs

if you want to debug the sql generated by bookshelf you can use the command line argument «--debug» or «--debug-db»

!function(){

	var   Class 		= require('ee-class')
		, log 			= require('ee-log')
		, BaseModel 	= require('ee-bookshelf-schema').BaseModel;



	module.exports = new Class({ 
		inherits: BaseModel

		// the name of your table
		, name: 'user'

		// the name of the id on this table if other than «id»
		, idAttribute: 'id'

		// the name of the collection
		, collection: 'users'

		// mapping
		, role: {
			belongsToMany: {
				  table: 	'user_role'
				, key: 		'id_user'
				, otherKey: 'id_role'
			}
		}

		// has many, the string is the fk in the other table
		, session: {
			hasMany: 'id_user'
		}

		// has one, the string is the fk in the other table
		, profile: {
			hasOne: 'id_user'
		}

		// belongs to, the string is the fk in this table
		, organization: {
			belongsTo: 'id_organization'
		}
	});
}();

Schema

var Schema = require('ee-bookshelf-schema');


var schema = new Schema({
	  dialect: 	'postgres'
	, host: 	''
	, port: 	
	, user: 	'postgres'
	, password: ''
	, database: 'wpm'
	, models: 	'./schema'
});



schema.on('load', function(){
	new schema.user({id: 11}).fetch().exec(function(err, user){
		log(err, JSON.stringify(user));
	});
});


// colelctions can be found on the colelction object
// schema.collection

CHANGELOG

  • 0.1.0: initial release
  • 0.1.1: added tests
  • 0.1.2: added correct collection initialization (@huliseerow)
  • 0.1.3: added the getDefinition method to the model
  • 0.1.4: collections have now the same name as the correponsing model if not specified other
  • 0.1.5: added command line arguments «--debug» && «--debug-db»
  • 0.1.6: the «getDefinition» method returns now more userful information
  • 0.1.7: bugfix release
  • 0.1.8: bugfix release
  • 0.1.9: added model property to the definition