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

rdbms-models

v1.0.5

Published

## Overview

Downloads

2

Readme

rdbms-models

Overview

rdbms-models is a framework that allows you to derive model classes from a MySQL database schema.

We provide four classes (Database, Table, Column, and Model).

The Database class is instantiated by passing in MySQL connection info, and then it fetches the tables and the columns (as a collection of Table, each of which contains of collection of Column) so you end up with a full javascript representation of your database schema, without the data.

The Model class is a base class which is meant to be extended into other classes. Think of a Model class as a Table with custom joins to other tables. These custom joins can be hardcoded, or better yet, you can define a rule to join all tables that match a certain criteria (for example, you can join all child tables or all foreign tables, etc).

The days of manually joining tables together in your application are over. Enjoy the ease of using this framework to reduce code building classes or REST APIs to fetch data from your database.

Database, Table, and Column class

For all intents and purposes, a Database is a collection of tables, and a Table is a collection of columns. Database, Table, and Column may store metadata information as well.

The main purpose of these classes is so that we can fetch the database's schema and use it inside of a Model class.

You instantiate a Database class like so:

var db = new Database("localhost","root","password","databaseName");
db.init();

The constructor will simply instantiate the database object, and init will fetch all of the tables, columns, and other necessary data related to the schema of the database.

By the end, you will have a Database which has a collection of Table, each of which has a collection of Column. Each Table will have it's primary keys and it's foreign keys made available, and if columns are foreign keys, it will be made available what columns they reference.

Model Class

It could be that we give an instance Table the power to fetch rows, so that articleTable.fetch(id) would return a table row from the article table. But, what if you want to join your table with another?

Models allow you to configure a table with a join and make it reusable across your application.