Skip to content

Latest commit

 

History

History
68 lines (40 loc) · 1.92 KB

README.md

File metadata and controls

68 lines (40 loc) · 1.92 KB

Prismany

Query any number of databases with Prisma

example.png

Commands

Generate

npx prismany generate

  • Generates a Prisma client for every schema in your ./prisma directory

  • Clients can be imported via

    import { PrismaClientSchemaName, PrismaClientSchemaName2 } from '@prismany/client';
    • Eg: ./prisma/myCoolDb.prisma can be imported from:
    import { PrismaClientMyCoolDb } from '@prismany/client';
  • Note: The generate command will add a "client.output" path to each of your .prisma files

Push

npx prismany push

  • Runs prisma db push against all of your schemas

  • If any push fails, or requires confirmation, the command will terminate and you'll need to push the individual schema manually: npx prisma db push --schema=./prisma/myDb.prisma

Other

If you'd like to see other Prisma features supported, like migrate, please open an issue.

Client Types

You can access your model types, and ORM input types like so:

// prisma client
import { PrismaClientDb1 } from '@prismany/client';
// advanced model, input types
import { Prisma, MyModel } from '@prismany/client/db1';

const db = new PrismaClientDb1();

const createModelInstance = (data: Prisma.MyModelCreateInput): Promise<MyModel> => {
  return db.myModel.create({ data });
};

How it works

This CLI takes an approach similar to this wonderful answer on Prisma's Github. It uses the client.output path in your Prisma schema to make sure clients don't overwrite each other.

Prismany automates much of the manual effort involved in that approach, and crucially, reuses the same engine binary for all clients.

This brings each client from a minimum of 15MB down to just 460kB each.

Example app

https://github.com/JoeRoddy/prismany-example