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

sequelize-inquirer

v1.0.3

Published

Quickly bootstrap a management CLI for sequelize models

Readme

sequelize-inquirer

The sequelize-inquirer package can be used to quickly develop a CLI tool that is centered around managing persistent database objects.

The package is aimed at users that have both experience with the sequelize as well as the inquirer packages and are in search for a package that glues those two together in a really cool way ;) Sequelize model definitions are used to automatically generate inquirer prompts for:

  • Creating a new instance
  • Updating an existing instance
  • Deleting one or more instances
  • Showing a (sub-)set of all model instances
  • ...

Thanks to awesome inquirer plugins such as autocomplete, sequelize-inquirer is able to handle even larger amounts of data by offering search functionality and pagination. However, the goal is to easily bootstrap the management of simple data objects that are most likely needed in the context of a CLI tool. sequelize-inquirer will reach its limits in terms of usability rather quick with more complex database structures.

Installation

Installation is straight forward with npm:

npm install sequelize-inquirer

Basic Usage

The minimal setup requires three folders to exist:

  • models: folder containing all sequelize model definitions
  • views: folder containing all CLI views (responsible for generating inquirer question arrays)
  • controllers: folder containing all CLI controllers (responsible for processing the user input that resulted from a view)

As you can see, sequelize-inquirer is using the MVC pattern to structure its code.

Let's setup our project accordingly:

├── cli.js
├── controllers/
├── models/
│   └── pet.js
└── views
    └── main-menu.js
// cli.js
const path = require('path');
const Sequelize = require('sequelize');
const Cli = require('../lib/sequelize-inquirer');

const sequelize = new Sequelize('petstore_db', '', '', {
  host: 'localhost',
  dialect: 'sqlite',
  storage: path.join(__dirname, 'petstore.sqlite'),
  operatorsAliases: false,
  logging: false,
});

const cli = new Cli(sequelize, {
  paths: {
    models: path.join(__dirname, 'models'),
    views: path.join(__dirname, 'views'),
    controllers: path.join(__dirname, 'controllers'),
  },
  banner: 'Welcome to the pet store!',
});

sequelize.sync().then(() => {
  cli.start('MAIN_MENU');
});
// models/pet.js
function initialize(sequelize, DataTypes) {
  return sequelize.define('pet', {
    name: DataTypes.STRING,
  });
}

module.exports = {
  initialize,
};
// views/main-menu.js
function initialize(sequelize, views) {
  class MainMenuView extends views.MenuView {
    constructor() {
      super('MAIN_MENU', ['PET_MENU']);
    }
    get label() { return 'Petstore menu'; }
  }

  return new MainMenuView();
}

module.exports = {
  initialize,
};

That's it! You are now able to create new pets, delete existing ones, show all pets or one pet in detail and much more, all out of the box!

Examples

The repository contains an example CLI project for operating the infamous pet-store.

API Documentation

Views

MenuView

Fragments

Model definition: CLI options object

You can extend the default sequelize model definition by a cli object containig all options revelant to that model's processing by the CLI. The following options are available:

| Name | Type | Default | Description | |--------------|--------|-------------------|------------------------------------------------------| | cli.label | String | model name | Label of the model | | cli.searchBy | String | model primary key | Attribute used for searching through model instances |

Example model definition

const pet = sequelize.define('pet', {
  name: DataTypes.STRING,
});
pet.cli = {
  label: 'awesome-pet',
  searchBy: 'name',
};

Debugging

The debug package is used for printing out debugging information. The main "namespace" of the sequelize-inquirer package is cli, you can therefore activate all debug messages by setting DEBUG=cli* and use more specific values (e.g. DEBUG=cli:view-generator) to only activate debug information for a specific module.

Maintainer

This package is developed and maintained by the guys at Decentro GmbH.