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

prismiq

v1.0.2

Published

A TypeScript-based language for defining database schemas and generating Prisma schemas

Readme

✨ Prismiq Schema Builder

A TypeScript-powered builder to generate Prisma-compatible schema files programmatically. Define models, fields, and relationships using a clean API and generate .prisma schemas effortlessly.


📦 Installation

Clone this repository and install dependencies:

npm install prismiq

🚀 Features

  • Programmatic Prisma schema generation
  • Define models and fields with types, defaults, primary keys, and unique constraints
  • Add One-to-One, One-to-Many, Many-to-One, and Many-to-Many relationships
  • Export the generated Prisma schema to a file
  • Reset and reuse the builder easily

SchemaBuilder Functions

This document explains the parameters for each function in the SchemaBuilder TypeScript class.

createModel(modelName: string)

Creates a new model with the specified name.

  • modelName: Name of the model to create.

addField(modelName: string, fieldName: string, type: Type, defaultValue?: Default, isUnique?: boolean)

Adds a field to an existing model with the specified attributes.

  • modelName: Name of the model to which the field belongs.
  • fieldName: Name of the field to add.
  • type: Type of the field. Supported types are "Int", "String", "Boolean", "Date", "float", "Json".
  • defaultValue (optional): Default value for the field (e.g., "cuid()", "uid()", "now()").
  • isUnique (optional): Specifies if the field should be unique.

setPrimaryKey(modelName: string, fieldName: string)

Sets the primary key for a field in a model.

  • modelName: Name of the model.
  • fieldName: Name of the field to set as the primary key.

addRelation(modelName: string, relationName: string, type: RelationType, relatedModel: string, inverseRelation?: string)

Defines a relationship between two models.

  • modelName: Name of the model where the relationship originates.
  • relationName: Name of the relationship.
  • type: Type of the relationship. Supported types are "OneToMany", "ManyToOne", "ManyToMany", "OneToOne".
  • relatedModel: Name of the related model.
  • inverseRelation (optional): Name of the inverse relationship.

generatePrismaSchema()

Generates a Prisma schema based on the configured models and relationships.

Returns: A string containing the generated Prisma schema.

savePrismaSchema(Filename: string)

Saves the generated Prisma schema to a file.

  • FileName: Identifier for the schema file.

reset()

Resets the SchemaBuilder instance by clearing all models and configurations.

🧠 Usage

📁 Import Functions

import {
  createModel,
  addField,
  setPrimaryKey,
  addRelation,
  generatePrismaSchema,
  getSchema,
  savePrismaSchema,
  reset
} from 'prismiq';

🔨 Create a Model

createModel("User");

🧱 Add Fields

addField("User", "id", "Int");
addField("User", "email", "String", undefined, true); // unique
addField("User", "createdAt", "Date", "now()"); // default now()

🔐 Set Primary Key

setPrimaryKey("User", "id");

👥 Add Relations

One-to-One

addRelation("User", "profile", "OneToOne", "Profile", "user");

One-to-Many

addRelation("User", "posts", "OneToMany", "Post", "author");

Many-to-One

addRelation("Post", "author", "ManyToOne", "User", "posts");

Many-to-Many

addRelation("User", "groups", "ManyToMany", "Group", "members");

📄 Generate Schema as String

const schemaString = generatePrismaSchema();
console.log(schemaString);

📂 Save Schema to File

savePrismaSchema("schema");
// Output: ./prisma/schema.prisma

♻️ Reset Builder

reset(); // clears all models and fields

💡 Example

createModel("User");
addField("User", "id", "Int");
addField("User", "email", "String", undefined, true);
setPrimaryKey("User", "id");

createModel("Profile");
addField("Profile", "id", "Int");
setPrimaryKey("Profile", "id");

addRelation("User", "profile", "OneToOne", "Profile", "user");

console.log(generatePrismaSchema());

🙏 Contributing

Feel free to open issues or submit pull requests!


🎓 License

MIT License