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 🙏

© 2024 – Pkg Stats / Ryan Hefner

seqlite

v0.0.3

Published

Scaffolder for sequelize models (Experimental)

Downloads

5

Readme

Seqlite [Experimental 🔬⚗]

Seqlite is a simple sequelize model builder. Enables the generation of sequelize models with very "lean" declarations - if braces and object declarations bore you. You can edit / augment the generated files with more sequelize configurations but seqlite provides a quick, easy (,faster?) way to getting started with model file creation.

Installation

npm install -g seqlite

Usage

seqlite <optional_schema_definition_file>

Schema Definition Files (SDFs)

Seqlite has a small parser that works with SDFs (Files containing the lean sequelize model declarations that become scaffolded into actual modelaname.js files). The SDF syntax is quite easy to understand:

modelname
modelattribute1, attribproperty1:value[... ,attribpropertyn:value]
modelattribute2,short_hand_attrib_property
###
anothermodelname
modelattribute, attribproperty1:value[... ,attribpropertyn:value]

The SDF dialect for attribproperty1:value / short_hand_attrib_property follows these mappings:

var property_map = {
	t:'type',
	pk:'primaryKey',
	ai:'autoIncrement',
	un:'unique',
	an:'allowNull',
	dv:'defaultValue'
};

//todo add more types
var shorthand_key_map = {
	PKD:'t:integer, pk:true, ai:true',
	S:'t:string',
	D:'t:double',
	I:'t:integer',
	U:'un:true',
	A:'an:true',
	T:'t:date'
}

Apart from shorthands, any value not in the property key map is used as is, e.g. if you do something like:

id, t:integer, somerandomthing:somerandvalue

The above will result in an id attribute being defined like so:

id:{
    type:DataTypes.INTEGER,
    somerandomthing:"somerandvalue"
}

An SDF example looks like so:

wallet
id, t:integer, pk:true, autoIncrement:true
username, t:string, un:true, dv:dontsaynever
email, su
expires, ta
###
wallet_ledger
id, pkd
un, su
walletid, ia

Assume the above is placed in a file named pp.txt. Running seqlite pp.txt will result in two files being created: wallet.js

"use strict"
module.exports = function (sequelize, DataTypes) {
  var schema_definition = {
	"id": {
		"type": DataTypes.INTEGER,
		"primaryKey": "true",
		"autoincrement": "true"
	},
	"username": {
		"type": DataTypes.STRING,
		"unique": "true",
		"defaultValue": "dontsaynever"
	},
	"email": {
		"type": DataTypes.STRING,
		"unique": "true"
	},
	"expires": {
		"type": DataTypes.DATE,
		"allowNull": "true"
	}
};
  var wallet = sequelize.define('wallet', schema_definition,{

     timestamps: true,
     paranoid: true,
     underscored: false,
     freezeTableName: true, 
     classMethods:{ 

      associate: function (models) {
  
      }


     }
  });

  return wallet;
}

wallet_ledger.js

"use strict"
module.exports = function (sequelize, DataTypes) {
  var schema_definition = {
	"id": {
		"type": DataTypes.INTEGER,
		"primaryKey": "true",
		"autoIncrement": "true"
	},
	"un": {
		"type": DataTypes.STRING,
		"unique": "true"
	},
	"walletid": {
		"type": DataTypes.INTEGER,
		"allowNull": "true"
	}
};
  var wallet_ledger = sequelize.define('wallet_ledger', schema_definition,{

     timestamps: true,
     paranoid: true,
     underscored: false,
     freezeTableName: true, 
     classMethods:{ 

      associate: function (models) {
  
      }


     }
  });

  return wallet_ledger;
}

[PS: The files are created in the directory seqlite is run in]