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

@biorate/sequelize

v2.3.2

Published

Sequelize ORM connector

Readme

@biorate/sequelize

Sequelize ORM connector — connection manager for Sequelize with model auto-loading and multi-connection support.

Features

  • Auto-connect — creates a Sequelize instance on @init() via the config namespace Sequelize.
  • Model auto-loading — declare models in a protected readonly models map on a connector subclass; they are attached to the matching named connection.
  • Connection verification — calls authenticate() after initialisation.
  • Multi-connection — named connections, each with its own model list.
  • Typed errors — SequelizeCantConnectError, UndefinedConnectionError.

Installation

pnpm add @biorate/sequelize

Requires @biorate/connector, @biorate/inversion, @biorate/config, and the peer dependencies sequelize (6.37.3) and sequelize-typescript (2.1.6).

Quick start

import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { SequelizeConnector, Table, Column, Model, DataType } from '@biorate/sequelize';

@Table({ tableName: 'users', timestamps: false })
export class User extends Model {
  @Column({ type: DataType.STRING, primaryKey: true })
  key: string;

  @Column(DataType.INTEGER)
  value: number;
}

// Declare the models for each named connection.
class AppSequelizeConnector extends SequelizeConnector {
  protected readonly models = { connection: [User] };
}

class Root extends Core() {
  @inject(AppSequelizeConnector) public connector: AppSequelizeConnector;
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container.bind<AppSequelizeConnector>(AppSequelizeConnector).toSelf().inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

container.get<IConfig>(Types.Config).merge({
  Sequelize: [
    {
      name: 'connection',
      options: {
        dialect: 'sqlite',
        storage: ':memory:',
        logging: false,
      },
    },
  ],
});

(async () => {
  const root = container.get<Root>(Root);
  await root.$run();

  await User.sync();
  await User.create({ key: 'test', value: 1 });

  const [row] = await root.connector.query<{ result: number }>(
    'SELECT $first + $second AS result',
    { bind: { first: 2, second: 2 } },
  );
  console.log(row); // { result: 4 }
})();

API Reference

SequelizeConnector

| Member | Type | Description | | ---------------------- | ------------------------------------------- | ---------------------------------------------------------------------------------------------- | | namespace | 'Sequelize' | Config key for connection definitions. | | models | { [name: string]: IModels } | Map of connection name → model list. Declared in a subclass. | | connect(config) | (config) => Promise<ISequelizeConnection> | Creates a Sequelize instance and authenticates; throws SequelizeCantConnectError on failure. | | query(sql, options?) | (sql, options?) => Promise<T[]> | Executes a raw query on the current (or named) connection. |

IModels is string[] | ModelCtor[].

query()

public async query<T = unknown>(
  sql: string | { query: string; values: unknown[] },
  options?: (QueryOptions | QueryOptionsWithType<QueryTypes.RAW>) & {
    connection?: string;
  },
): Promise<T[]>

Runs the query on the connection named by options.connection, or on current when omitted. Throws UndefinedConnectionError when the referenced connection does not exist.

Config

interface ISequelizeConfig extends IConnectorConfig {
  host: string;
  options: Options & { models?: IModels }; // dialect, host, port, username, password, database, storage, ...
}

Errors

| Error | Condition | | --------------------------- | ------------------------------------------------------ | | SequelizeCantConnectError | new Sequelize() or authenticate() fails. | | UndefinedConnectionError | query() references a connection that does not exist. |

Architecture

SequelizeConnector extends Connector<ISequelizeConfig, ISequelizeConnection>
│
├── namespace = 'Sequelize'
├── models = { [name]: IModels }   // declared in a subclass
├── connect(config) → new Sequelize({ ...config.options, models })
│   └── await connection.authenticate()
│
├── query(sql, options?) → connection.query(...)
│   └── throws UndefinedConnectionError for an unknown connection name
│
└── connection is a Sequelize instance (sequelize-typescript) with the declared models attached

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT