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

jane

v0.7.1

Published

Jane is an extensible code generator which allows you to generate SQL queries to create, drop and populate your database based on its XML data description.

Downloads

11

Readme

jane

Introduction

Jane is an extensible code generator which allows you to generate SQL queries to create, drop and populate your database based on its data description. You describe these data in XML and Jane will then generate SQL queries for you, for the desired RDBMS (can be anything as long as there's a generator for it).

In short, it allows you to turn this:

<entity name="Product" plural="Products">
  <attributes>
    <attribute name="id" type="Integer" primary-key="true" />
    <attribute name="name" type="String" max-length="63" />
    <attribute name="price" type="Decimal(5,2)" />
    <attribute name="description" type="String" max-length="1023" />
    <attribute name="stock" type="Integer" />
  </attributes>
  <references>
    <reference entity="ProductCategory" attribute="id" as="category" />
  </references>
</entity>

into this (for MySQL) :

CREATE DATABASE IF NOT EXISTS MyDatabaseName;
USE MyDatabaseName;

CREATE TABLE Products (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(63) NOT NULL,
  price DECIMAL(5,2) NOT NULL,
  description VARCHAR(1023) NOT NULL,
  stock INT NOT NULL,
  category INT NOT NULL,

  FOREIGN KEY (category) REFERENCES ProductsCategories (id)
);

or this (for SQLite) :

CREATE TABLE Products (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name VARCHAR NOT NULL,
  price DECIMAL(5,2) NOT NULL,
  description VARCHAR NOT NULL,
  stock INTEGER NOT NULL,
  category INTEGER NOT NULL,

  FOREIGN KEY (category) REFERENCES ProductsCategories (id)
);

Jane is RDBMS and programming language agnostic. You can use one of the generators supported by default or write your own generator to generate isolated model classes for a specific programming language, whole APIs or to add support for another RDBMS, everything based only on your data description.

Jane is an object-oriented method and only requires to know the basics of programming (including XML or HTML) to be used. However if you want to write your own generator or to modify an existing one, JavaScript (ES6) knowledge is required.

Installation

Coming soon to NPM. In the meantime just clone the repo locally :

git clone https://github.com/flawyte/jane.git
cd jane

Usage

node index.js <generator-name> --from <XML file/directory> [<generator-specific arguments>]
  • generator-name : See the list of supported generators above or add your own.
  • from : Relative path to a Jane-compliant XML source file or to a whole directory (each XML file it contains will be processed). See the XML files in one of the tests/example*/ directories
  • generator-specific arguments : Type node index.js <generator-name> --help for a list of additional arguments supported by a generator if any

For example, if you want to generate the SQL code to create, drop and insert some data, say 5 rows in each table, into the SQLite database corresponding to tests/example1/ :

node index.js sqlite --from tests/example1/ --create --drop --insert-into=5

And see the output files in tests/example1/generated/sqlite/.

Supported generators

Currently supported generators by default :

  • MySQL
  • PostgreSQL
  • SQLite
  • JS/ES6 (work in progress, very basic support)