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 🙏

© 2026 – Pkg Stats / Ryan Hefner

semo-plugin-sequelize

v2.0.14

Published

A Semo plugin to provide integration with Sequelize module.

Readme

semo-plugin-sequelize

A Semo plugin to privide sequelize integration in Semo way.

CLI Usage

npm i semo-plugin-sequelize

semo sql cli <dbKey>                               Connect with pgcli/mycli/sqlite3 connector
semo sql describe <dbKey> <tableName>              Sequelize db table describe                      [aliases: d, desc]
semo sql generate <dbKey> <tableName> [fieldName]  Sequelize db migration generator               [aliases: g, create]
semo sql list <dbKey>                              List all table of specific database                [aliases: l, ls]
semo sql query <dbKey> <sql>                       Execute SQL, only support SELECT                       [aliases: q]

Programming way

npm i @semo/core semo-plugin-sequelize
semo init

Add migration config and dbConfig in .semorc.yml


# Useful for migration
migrationMakeDir: src/migrations
migrationDir: lib/migrations

semo-plugin-sequelize:
  defaultConnection: dbKeyStyle1 # if provided, commands do not need --db-key
  connection:
    dbKeyStyle1:
      database: d8
      username: d8
      password: d8
      host: localhost
      port: 5432
      dialect: postgres
    dbKeyStyle2: postgres://d8:d8@localhost:5432/d8

Except adding db connection info in .semorc.yml, also we can declare that info in hook_sequelize_connection.

// src/hooks/index.ts

const export hook_sequelize_connection = async () => {
  return {
    dbKeyStyle1: {
      database: 'd8',
      username: 'd8',
      password: 'd8',
      host: 'localhost',
      port: 5432,
      dialect: 'postgres'
    }
  }
}

You may have noticed, there is a async for the hook_sequelize_connection, it's useful for fetching db config from config center.

This plugin support 3 dialects: mysql, postgres, sqlite, and support 2 style's config format: literal object and DSN.

Add .sequelizerc file for migration

const path = require('path');

const SequelizeOps = process.argv.slice(2).join(' ')

// Operations with care
if (SequelizeOps.indexOf('undo') > -1 && process.env.NODE_ENV === 'production') {
  throw new Error('Sequelize undo disabled on production')
}

module.exports = {
  'config': path.resolve('config.db.js'),
  'migrations-path': path.resolve('lib/migrations'),
}

Add config.db.js for migration to connnect to db

/**
 * @file
 *
 * For Sequelize Cli db connection
 */

module.exports = require('semo-plugin-sequelize').sequelize.getConfig('dbKey')

Here, sequelize-cli only can choose to use one database to migrate.

Access db instance and table model.

import { Utils } from '@semo/core'

const { sequelize } = await Utils.invokeHook('semo:component')
const { Op, Sequelize } = sequelize
const { db, models: { YourModel } } = await sequelize.load('dbKey)
const count = await YourModel.count({
  where: {
    id: {
      [Op.gt]: 3
    }
  }
})

To use cli command, you need to install related cli tools. This is an example on MacOS

brew install pgcli # For PostgresSQL
brew install mycli # For MySQL

Access database in REPL

This plugin has expose objects and methods to REPL, so you can assess db data from REPL.

$ semo repl --hook
>>> const { models: { YourModel } } = await Semo.sequelize.load('dbKey')
>>> YourModel.count()
2

License

MIT