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

auto-pool-data

v1.0.0

Published

Database model package for auto-pool-data with Sequelize and PostgreSQL support.

Readme

auto-pool-data

A reusable Sequelize package that provides inventory, warehouse, purchase order, and sales order management models for PostgreSQL.

The package uses your application's existing Sequelize instance and creates only the tables managed by this package without affecting your application's existing models or data.


Features

  • Uses your existing Sequelize connection
  • No additional database connections are created
  • Creates only package-specific tables
  • Existing tables and data remain unchanged
  • Supports PostgreSQL and Sequelize v7
  • Ready-to-use inventory and order management models
  • Models can be imported and used directly

Included Models

The package provides the following Sequelize models:

  • Warehouse
  • Inventory
  • PurchaseOrder
  • PurchaseOrderItem
  • SalesOrder
  • SalesOrderItem
  • SalesOrderItemAllocation

Installation

Install the package:

npm install auto-pool-data

Install required peer dependencies:

npm install @sequelize/core @sequelize/postgres pg

Project Setup

Step 1: Configure Sequelize

Create your Sequelize instance.

config/database.ts

import { Sequelize } from "@sequelize/core";
import { PostgresDialect } from "@sequelize/postgres";

export const sequelize = new Sequelize({
  dialect: PostgresDialect,

  database: process.env.DB_NAME,
  user: process.env.DB_USER,
  password: process.env.DB_PASS,

  host: process.env.DB_HOST,
  port: Number(process.env.DB_PORT ?? 5432),

  logging: false,

  pool: {
    max: 20,
    min: 5,
    idle: 10000,
    acquire: 30000,
  },
});

Step 2: Initialize Package Models

Before using any package model, initialize the package with your Sequelize instance.

import { initializeAutoPoolData } from "auto-pool-data";
import { sequelize } from "./config/database";

await initializeAutoPoolData(sequelize);

This registers all package models with your application's Sequelize instance.


Important

You must initialize the package before using any exported model.

await initializeAutoPoolData(sequelize);

If initialization is skipped, Sequelize will throw an error similar to:

Model Warehouse has not been initialized yet.

Creating Package Tables

To create package tables:

import { syncAutoPoolData } from "auto-pool-data";

await syncAutoPoolData(true);

This creates only the tables managed by this package.

Existing tables are preserved.

Existing data is preserved.

No application-specific models are synced.


Sync Options

await syncAutoPoolData(sync);

| Value | Description | |---------|-------------| | true | Create package tables if they do not exist | | false | Skip table creation |


Default Behavior

await syncAutoPoolData();

or

await syncAutoPoolData(false);

Result:

No tables are created.

Recommended Usage

During first-time setup:

await initializeAutoPoolData(sequelize);
await syncAutoPoolData(true);

After tables have been created:

await initializeAutoPoolData(sequelize);
await syncAutoPoolData(false);

or simply:

await initializeAutoPoolData(sequelize);

Using Models

All models can be imported directly from the package.

import {
  Warehouse,
  Inventory,
  PurchaseOrder,
  PurchaseOrderItem,
  SalesOrder,
  SalesOrderItem,
  SalesOrderItemAllocation,
} from "auto-pool-data";

Example: Create Warehouse

import { Warehouse } from "auto-pool-data";

await Warehouse.create({
  name: "Main Warehouse",
});

Example: Get All Warehouses

const warehouses = await Warehouse.findAll();

Complete Example

import { app } from "./app";

import {
  initializeAutoPoolData,
  syncAutoPoolData,
  Warehouse,
} from "auto-pool-data";

import { sequelize } from "./config/database";

const PORT = 5000;

const start = async () => {
  // Initialize package models
  await initializeAutoPoolData(sequelize);

  // Create package tables if missing
  await syncAutoPoolData(true);

  // Use package models
  await Warehouse.create({
    name: "Warehouse 1",
  });

  app.listen(PORT, () => {
    console.log(`Server running on ${PORT}`);
  });
};

start();

SalesOrderItemAllocation

SalesOrderItemAllocation.create({
  sales_order_item_id: 1,
  warehouse_id: 1,
  quantity: 5,
});

Exported APIs

initializeAutoPoolData

Initializes package models using your Sequelize instance.

await initializeAutoPoolData(sequelize);

Returns:

{
  Warehouse,
  Inventory,
  PurchaseOrder,
  PurchaseOrderItem,
  SalesOrder,
  SalesOrderItem,
  SalesOrderItemAllocation
}

syncAutoPoolData

Creates package tables.

await syncAutoPoolData(true);

Notes

  • Uses your application's Sequelize instance.
  • Does not create a new database connection.
  • Does not call sequelize.sync() globally.
  • Only package models are synced.
  • Existing application models are not affected.
  • Existing database tables remain unchanged.
  • Existing data is never deleted.

Requirements

  • Node.js 18+
  • PostgreSQL
  • Sequelize v7

License

ISC License