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

@text2order/sequelize-models

v0.0.37

Published

A collection of database models for use with [Sequelize ORM](https://sequelize.org/).

Readme

Sequelize Models

A collection of database models for use with Sequelize ORM.

Table of Contents

tldr;

Install dependencies:

npm i or npm install

To apply schema changes to a database:

npm run migrate:up

To verify that the database you are running against is compatible with your version of the schema:

npm run checkSchema

Getting Started

Configuration

Using the models requires that the following environment variables are set:

  • DATABASE_HOST
  • DATABASE_DB_NAME
  • DATABASE_USER
  • DATABASE_PASSWORD
  • DATABASE_LOGGING (set to "off" to turn logging off)
  • MODEL_CHANGE_LOGGING (set to "off" to turn model change logging off)
  • DB_POOL_MAX (database max connection pool. If not set, default to 5)
  • DB_POOL_MIN (database min connection pool. If not set, default to 0)
  • DB_POOL_ACQUIRE (database acquire. If not set, default to 30000)

Using dotenv

Copy the .env-template file to .env and set variables accordingly.

How to publish

This package is published but a github action. For this action to work bump the package version according to semver and push. (Right now this package is still considered in beta so do NOT publish a major version ex 1.0.0) as long as the package version is newer it will publish it to npm. Once it is published you can update the version numbers in the applications that use this package.

Migrations

Gotchas

If you are writing a migration that removes a column make sure that you do this in two steps. First release a change that removes the column from the model. Make sure that all applications using this package have that version. Affer all applications are on that version write the migration to remove it from the database. This is becasue a model in an application that is not updated might reference the column and if it is not on the database it will throw an error.

How to check if there are migrations to run

npm run migrate:check

How to create

To create a migration run npm run migrate:create [migrationName]

This creates an up and down migration in the migrations/sqls directory and create the js file in migrations. To add your migrations to these files write plane sql in the corresponding up and down file to add and remove your change.

Once your migration is added you will also need to make the change to the model in src/models/[modelName]

How to run migrations

To run migartions run npm run migrate:up

How to undo a migration

To undo the last migration run npm run migrate:down

Testing

Running Tests

Database Setup

The unit tests in this repository require a local MySQL instance and will modify the data in that database. A .env file should be created including environment variables specific to the test environment as found in config/database.json in addition to the environment variables specified above.

DATABASE_HOST_TEST=localhost
DATABASE_NAME_TEST=vector-test
DATABASE_USER_TEST=test
DATABASE_PASSWORD_TEST=test

The variables DATABASE_NAME_TEST, DATABASE_USER_TEST, and DATABASE_PASSWORD_TEST are used in setting up MySQL and can be set to almost any valid string.

Run Tests

npm test