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

@node-tenant/tenant-storage-prisma

v0.1.2

Published

Prisma storage adapter for @node-tenant/tenant

Downloads

198

Readme

@node-tenant/tenant-storage-prisma

Prisma storage adapter for the @node-tenant ecosystem — manages tenant metadata, relationships, and configuration using Prisma ORM.

🌐 Website: node-tenant.com

npm version license


Overview

@node-tenant/tenant-storage-prisma implements the TenantStorage interface from @node-tenant/tenant-core. It acts as the "Control Plane", storing your tenants, their configurations, statuses, and cross-tenant relationships.

Note: This package does not handle tenant data isolation (that's the job of the DatabaseAdapter or Mongoose routers). This package only manages the list of tenants themselves.


Table of Contents


Installation

npm install @node-tenant/tenant-core @node-tenant/tenant-storage-prisma @prisma/client

Peer dependency: @prisma/client >= 5.0.0 must be installed in your project.


Prisma Schema

This package requires a specific set of models in your schema.prisma file. A pre-defined schema is included in this package at node_modules/@node-tenant/tenant-storage-prisma/schema.prisma.

You can manually copy these models into your own schema.prisma:

model Tenant {
  id             String   @id @default(uuid())
  slug           String   @unique
  name           String
  status         String   // e.g., 'active', 'suspended', 'inactive'
  strategy       String   // e.g., 'tenantId', 'database', 'schema'
  config         Json?    @default("{}")
  organizationId String?
  createdAt      DateTime @default(now())
  updatedAt      DateTime @updatedAt
}

model TenantRelationship {
  id             String   @id @default(uuid())
  sourceTenantId String
  targetTenantId String
  type           String   // e.g., 'partner', 'parent_child'
  metadata       Json?    @default("{}")
  createdAt      DateTime @default(now())
  updatedAt      DateTime @updatedAt

  @@unique([sourceTenantId, targetTenantId, type])
}

model TenantShare {
  id             String   @id @default(uuid())
  resourceType   String
  resourceId     String
  ownerTenantId  String
  targetTenantId String
  permission     String   // e.g., 'read', 'write', 'admin'
  metadata       Json?    @default("{}")
  createdAt      DateTime @default(now())
  updatedAt      DateTime @updatedAt

  @@unique([resourceType, resourceId, ownerTenantId, targetTenantId])
}

After adding these to your schema, run:

npx prisma generate
npx prisma db push # Or create a migration

Quick Start

import { PrismaClient } from '@prisma/client';
import { TenantManager } from '@node-tenant/tenant-core';
import { createPrismaStorage } from '@node-tenant/tenant-storage-prisma';

// 1. Initialize your Prisma Client
const prisma = new PrismaClient();

// 2. Create the Storage Adapter
const storage = createPrismaStorage(prisma);

// 3. Pass to the TenantManager
const manager = new TenantManager({ storage });

// Now you can manage tenants!
async function setup() {
  const tenant = await manager.createTenant({
    slug: 'acme-corp',
    name: 'Acme Corporation',
    status: 'active',
    strategy: 'tenantId',
  });
  
  console.log('Created tenant:', tenant);
}

API Reference

createPrismaStorage(prismaClient)

Creates a TenantStorage compatible adapter.

import { createPrismaStorage } from '@node-tenant/tenant-storage-prisma';
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();
const storage = createPrismaStorage(prisma);

| Parameter | Type | Required | Description | |---|---|---|---| | prismaClient | PrismaClient | ✅ | An initialized PrismaClient instance |

Returns: TenantStorage object containing all required methods (getTenantById, getTenantBySlug, listTenants, createTenant, updateTenant, deleteTenant, createRelationship, etc.)


License

MIT © Anupam Vishwakarma