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

sequelize-store

v0.4.2

Published

Key Value store backed by Sequelize

Readme

Sequelize Store

CircleCI Dependency Status standard-readme compliant js-standard-style Managed by tAsEgir

Key Value store backed by Sequelize

Table of Contents

Install

$ npm install sequelize-store

This package requires Sequelize as peer-dependency, but that should be already satisfied because most probably you will use this package in projects where it is already present. In case not just run:

$ npm install sequelize

Usage

There are four steps you have to do:

  1. Define schema and initialize SequelizeStore
  2. Retrieve the store's object
  3. Set / retrieve values as you like
  4. Profit
import {init, getObject, getEndPromise} from 'sequelize-store'

const sequelize = sequelizeFactory()

// Define schema and init
await init(sequelize, {
  adminId: 'int', // Lets say this was already set previously and hence is pesisted in DB
  secretToken: { type: 'string', default: 'notSoRandomSecret' },
  someCoolObject: 'json',
  scope1_id: 'int',
  scope1_name: 'string'
})

const store = getObject()
console.log(store.secretToken) // --> 'notSoRandomSecret'
console.log(store.adminId) // --> undefined

store.adminId = 5
console.log(store.adminId) // --> 5

delete store.adminId
console.log(store.adminId) // --> undefined
console.log(store.adminId) // --> 5

// Scopes
store.scope1_id = 10
const scopedStore = getObject('scope1_')
console.log(scopedStore.id) // --> 10
console.log(scopedStore.name) // --> undefined

// Lets await for everything to be committed to database
await getEndPromise()

Schema

Schema is an object that defines the structure of the Store. Supported types are: bool, int, float, json, string.

The Schema has two following formats

{
 'key-name': <<type string>>,
 otherKeyName: {
   type: <<type string>>,
   default: 'some default'
 }
}

API

init(sequelize: Sequelize, schema: Schema, options?: StoreOptions) -> Promise<void>

Initialize SequelizeStore for usage

Parameters:

  • sequelize: Sequelize (required) - Instance of Sequelize
  • schema: Schema (required) - Object defining the Schema of the store
  • options - Store's options
    • options.tableName: string - string defining name of the table where the data should be stored

getObject(scope?: string) -> object

Returns the Store objects which is a singleton, so you can call it anywhere (after initialization!)

Parameters:

  • scope?: string - The returned object will be scoped to given scoped. That means that all keys will prefixed with the string.

purge() -> Promise<void>

Delete all data in database and the local cache

getEndPromise() -> Promise<void>

Function that returns a Promise that is resolved when the DB processing queue is finished with all the pending transactions. If queue is empty Promise is resolved right away.

Contribute

There are some ways you can make this module better:

  • Consult our open issues and take on one of them
  • Help our tests reach 100% coverage!

License

MIT