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

syp-model

v1.0.10

Published

Simple yet powerful promise-based database model for Node.js

Readme

:heavy_check_mark: syp-model

Simple yet powerful model

Simple yet powerful promise-based database model for Node.js

Author: Tuhin Paul :phone: Mobile :email: Email

January 16, 2018


Before using the model, you need to provide following configurations using the static Model::config(connectionParameters, modelConf) method:

  • connection parameters
  • model configurations

Currently, the model works for mysql. Support for other database systems will be added soon.

Example of using static Model::config(connectionParameters, modelConf):

/* provide database connection configuration as follows: */
let dbConnConf = {
	"host"               : "<mysql host>",
	"user"               : "<mysql username>",
	"password"           : "<mysql password>",
	"database"           : "<database name>",
	"multipleStatements" : true,
	"pool"               : { "maxConnections": 20, "maxIdleTime": 30}
}

/** you provide the information of the models and corresponding
    tablename and column names to Model::config() method as follows.
    Suppose, following three tables exist in the database:
        users, categories, and currencies. */
let dbConf = {
	"User": {
		"tablename": "users",
		"columns": [
			"id",
			"role_id",
			"name",
			"username",
			"email",
			"password",
			"status",
			"last_login_on"
		]
	},

	"Category": {
		"tablename": "categories",
		"columns": [
			"id",
			"domain_id",
			"name",
			"parent_id",
			"description"
		]
	},

	"Currency": {
		"tablename": "currencies",
		"columns": [
			"id",
			"code",
			"name"
		]
	},
}

/* configuration information before using Model */
Model.config(dbConnConf, modelConf) {

After passing the configuration information, you can use the Model class as shown in the following code snippet. Note that we have a table :

let data = {}
Model.factory('Category').select()
.then(categories => {
	data['categories'] = categories;
	return Model.factory('Currency').select()
})
.then(currencies => {
	data['currencies'] = currencies;
	
	/* debug page data */
	console.log('Page Data')
	console.log(data)

	/* render() is a custom method I wrote to render a view */
	// suppose I am using PUG (https://pugjs.org/):
	this.render('all-categories', data)
})
.catch(err => {
	/* renderError is a custom method I wrote to render error */
	this.renderError(err);
})