GithubHelp home page GithubHelp logo

ovyerus / prismaliser Goto Github PK

View Code? Open in Web Editor NEW
805.0 805.0 42.0 2.93 MB

Visualise your Prisma schema!

Home Page: https://prismaliser.app

License: MIT License

JavaScript 1.66% CSS 1.90% TypeScript 91.74% SCSS 1.32% Dockerfile 2.38% Nix 1.00%
graph hacktoberfest nextjs nix-flake prisma react react-flow typescript visualization

prismaliser's Introduction

big nerd

prismaliser's People

Contributors

dravorle avatar eric-hc avatar henriqueleite42 avatar mariannakrzewinska avatar ovyerus avatar raisess avatar renovate-bot avatar renovate[bot] avatar ruheni avatar sapphicmoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

prismaliser's Issues

Don't format things on top of each other

Not looking for any smart formatting based on relationships, but defaulting to everything just being centred and on top of each other makes me sad ๐Ÿฅฒ

Love the app though, great work โค๏ธ

Screenshot 2022-04-27 at 11 50 00

Couldn't create edge source (1:1)

This is a weird one. If I define the relation on my "UserProfile"-Model the console gets spammed by warnings:
couldn't create edge for source handle id: User-UserToUserProfile-UserProfile; edge id: eUserToUserProfile

If you however switch it around and define the relation on the side of the user model it works. Any Idea whats wrong there?

NOT WORKING:

model User {
  id       String @id @unique @default(uuid()) @db.Char(36)
  username String @unique @db.VarChar(255)

  UserProfile UserProfile?
}

model UserProfile {
  id    String  @id @unique @db.Char(36)
  about String? @db.LongText

  User User @relation(fields: [id], references: [id])
}

WORKING:

model User {
  id       String @id @unique @default(uuid()) @db.Char(36)
  username String @unique @db.VarChar(255)

  UserProfile UserProfile @relation(fields: [id], references: [id])
}

model UserProfile {
  id    String  @id @unique @db.Char(36)
  about String? @db.LongText
  
  User  User?
}

in next.js 13.4.13, an error saying Error: Invariant: Expected relative import to start with "next/", found "[email protected]@next/dist/server/future/route-kind

i install the app but running with an error saying
'Error: Invariant: Expected relative import to start with "next/", found "_next@13.4.13@next/dist/server/future/route-kind"'

It looks like the version compatibility with next.js 13.4.13. When the next.js version rolls back to 13.4.8, it works well.

But just wondering, how would I modify the code in order to make it adapt to the latest next.js version

HTTP ERROR 431

Hello there,

After I hit copy link and I paste the link in the browser it gives me 431.

Any idea why might that happen ?

Here is the link

Thank you.

` title String @db.VarChar(255)` leads to `Attribute not know: "@db.VarChar"`

Currently for default schema on https://prismaliser.ovy.cloud/

image

Removing the native type definition fixes the problem of course.

Maybe db is not defined as the datasource name that is sent in as validation? Could be that you have to add that (or just include it in the default schema for the validation to be able to pick it up from there).

Update: Yep, adding this to the default schema makes it work:

datasource db {
  provider = "mysql"
  url = "mysql://foo"
}

Client side formatting

Prisma v4.3.0 mentions that the prisma format command now uses a WASM module (@prisma/prisma-fmt-wasm).

Currently formatting is done via an API endpoint which uses the @prisma/internals package. It might be worth looking into seeing how hard it is to commandeer this WASM module to provide schema formatting on the client side, without needing to call out to the API.

Shareable link

Hey @Ovyerus ๐Ÿ‘‹๐Ÿฝ

A nice-to-have feature would be creating a project with the schema and inviting others or being able to share the link to your schema with someone else

Show MongoDB embedded documents as nodes

When using MongoDB as a datasource, users are able to specify embedded documents with the type keyword. We don't currently handle this but I reckon it would be nice to. Reference

Example schema

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model MyModel {
  id    String   @id @default(auto()) @map("_id") @db.ObjectId
  types MyType[]
}

type MyType {
  value  String
  public Boolean
}

Dependabot/ Renovate setup

I can take care of this โ€“ setting up renovate or dependabot to handle updating the Prisma versions if you'd like ๐Ÿ™‚

Do you have any preference?

Feature Discussion

Just came across this and am excited after looking around for a long time for a self hostable Prisma schema visualiser. Below are some of the minimal use cases that I've been looking for from a package like this and it would be good to get your input on what they would look like and whether you've already considered them.

  • Ability to install using a package manager and run via cli. e.g.
    yarn add prismaliser --dev

  • Ability to pass the schema file via argument to docker run or cli
    docker run -p 3000:3000 ghcr.io/ovyerus/prismaliser --schema=<path-to-schema-file.prisma>
    or
    yarn prismaliser run --schema=<path-to-schema-file.prisma>

  • VScode extension that can automatically be opened to the side when a schema.prisma file is opened. Similar to bicep visualiser.

Rewrite schema to nodes parser

The current implementation is wonky and doesn't actually explain some of the decisions I made years, needs to be rewritten to be better and actually documented. Also because I've found the cause for #45 but it seems hard to fix in the current state sadly.

Application throws an error when using embedded documents with MongoDB

I'm using Prisma together with MongoDB and utilize embedded documents.

When I paste in the following example that makes use of this:

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model MyModel {
  id    String   @id @default(auto()) @map("_id") @db.ObjectId
  types MyType[]
}

type MyType {
  value  String
  public Boolean
}

I recieve the following error:

Application error: a client-side exception has occurred (see the browser console for more information).

With the following console output:

TypeError: Cannot read properties of undefined (reading 'isList')

I can imagine this happens because Prismaliser was last released before Prisma started supporting embedded documents.

Possible to feed my local schema file?

Hi!

I didn't get if it's possible to feed my local schema file when launching visualizer or even better when udpates in preview and locally are synced?

One to Many Relationship Backwards

In the visualizer, the crows feet point to the "one" instead of pointing to the "many".

model Person {
  id      Int       @id @default(autoincrement())
  friends Friends[]
}

model Friends {
  id       Int     @id @default(autoincrement())
  Person   Person? @relation(fields: [personId], references: [id])
  personId Int?
}

image

Shouldn't it be the other way around?

connecting lines not displaying for One to One relationship

reproduce: Insert example code on the Prismalizer app

model User {
  id      Int      @id @default(autoincrement())
  profile Profile?
}

model Profile {
  id     Int  @id @default(autoincrement())
  user   User @relation(fields: [userId], references: [id])
  userId Int  @unique // relation scalar field (used in the `@relation` attribute above)
}

expect: connecting lines for one-to-one relationship between models.
output: Models without connecting lines for one to one model

Feature to export the preview as image

It would be really nice if we could export the preview as an image. This could have usecases where we want to store it as documentation or include it in a website

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.