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

@miinded/nestjs-db-options

v1.0.1

Published

Production-ready NestJS module for database options management with TypeORM integration.

Readme

@miinded/nestjs-db-options

npm version License: MIT

Production-ready NestJS module for database-backed key/value options management with TypeORM. Store and retrieve typed application configuration from your database with pattern-based search.

Features

  • 🗄️ Database-backed — Options stored in a TypeORM entity, persisted across restarts
  • 🔤 Typed Formatsstring, int, float, json with automatic serialization
  • 🔍 Pattern Search — Find options by key pattern with getAll
  • 📦 TypeORM Integration — Works with any TypeORM-supported database (PostgreSQL, MySQL, SQLite…)
  • 🚀 Ready-to-use Migration — Ships a TypeORM migration to create the options table
  • 📝 Full TypeScript — Complete type definitions for excellent DX
  • Well Tested — Unit tests with 80%+ coverage

Installation

npm install @miinded/nestjs-db-options
# or
pnpm add @miinded/nestjs-db-options
# or
yarn add @miinded/nestjs-db-options

Quick Start

1. Register the module

import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { DbOptionsModule } from '@miinded/nestjs-db-options';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      // ... your TypeORM config
    }),
    DbOptionsModule,
  ],
})
export class AppModule {}

2. Add the migration

The module ships a ready-to-use TypeORM migration to create the options table:

import { OptionsMigration } from '@miinded/nestjs-db-options';

// In your DataSource or TypeORM config
migrations: [OptionsMigration],

3. Inject and use OptionService

import { Injectable } from '@nestjs/common';
import { OptionService } from '@miinded/nestjs-db-options';

@Injectable()
export class AppConfigService {
  constructor(private readonly options: OptionService) {}

  async getMaxRetries(): Promise<number> {
    return this.options.get<number>('app.max_retries', 'int');
  }

  async setMaintenanceMode(enabled: boolean): Promise<void> {
    await this.options.set('app.maintenance', enabled, 'json');
  }

  async getFeatureFlags() {
    return this.options.gets(['feature.darkMode', 'feature.betaApi'], 'json');
  }
}

Usage Example

import { Injectable, OnModuleInit } from '@nestjs/common';
import { OptionService } from '@miinded/nestjs-db-options';

@Injectable()
export class SettingsService implements OnModuleInit {
  constructor(private readonly options: OptionService) {}

  async onModuleInit() {
    // Set a default if not present
    const retries = await this.options.get<number>('app.max_retries', 'int');
    if (!retries) {
      await this.options.set('app.max_retries', 3, 'int');
    }
  }

  async findAllRateLimits() {
    // Find all options whose key starts with 'rate_limit.'
    return this.options.getAll('rate_limit.%', 'int');
  }
}

API Reference

OptionService

| Method | Signature | Description | | -------- | ------------------------------------------------------------------- | --------------------------------------- | | get | <T>(key: string, format: OptionFormat) => Promise<T> | Get a single option by exact key | | getAll | <T>(pattern: string, format: OptionFormat) => Promise<T[]> | Get all options matching a LIKE pattern | | gets | <T>(keys: string[], format: OptionFormat) => Promise<T[]> | Get multiple options by key list | | set | <T>(key: string, value: T, format: OptionFormat) => Promise<void> | Create or update an option |

OptionFormat

| Value | Description | | -------- | ------------------------------------------------------------- | | string | Plain string — stored and returned as-is | | int | Integer — parsed via parseInt | | float | Float — parsed via parseFloat | | json | JSON object — serialized with JSON.stringify / JSON.parse |

Exports

| Symbol | Description | | ------------------ | ----------------------------------------------- | | DbOptionsModule | Main module | | OptionService | Service for reading and writing options | | OptionRepository | TypeORM repository for the OptionEntity | | OptionEntity | TypeORM entity representing a single option row | | OptionsMigration | TypeORM migration to create the options table |

License

MIT © Miinded