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 🙏

© 2024 – Pkg Stats / Ryan Hefner

prisma-generator-go-jet

v0.0.4

Published

Provide a description about your generator

Downloads

156

Readme

Prisma Generator for Go Jet

This is a generator for Prisma to output Go Jet code. Prisma is a modern database toolkit used for data access in various applications and services and Go Jet is a type-safe SQL query builder for the Go programming language. This generator specifically targets Go Jet and is only useful in conjunction with Go Jet.

Installation

To use this generator, you must first install it. You can install it using your package manager of choice:

yarn add prisma-generator-go-jet

Once the generator is installed, replace the default client generator in your schema.prisma file with the following:

generator go-jet {
    provider = "prisma-generator-go-jet"

    // Optionally provide a destination directory for the generated file
    // and a filename of your choice. The default is `../generated`
    output = "../types"

    // Optionally change which packages enums, models or tables are generated to,
    // relative to the output. These are the recommended options:
    outputModels = "model"
    outputTables = "table"
    outputEnums = "enum"

    // Optionally change which schema your database is using
    schemaName = "public"
}

Usage

After generating the code, you can use it within your Go project. The generated code includes models, tables, and enums based on your Prisma schema. For more information how to use this, read the go-jet documentation.

Limitations

  • Postgres arrays

    • Basic support for Postgres string and int arrays exist, but expect limitations.
    • Models get the pq.StringArray and pq.IntArray types, but the tables are still StringColumn and IntegerColumn.
  • Breaking changes

    • Expect breaking changes while the package is <1.x.x.
    • After, it follows Semver, with only breaking changes each major version.

Contributing

Contributions are welcome! If you have any improvements or bug fixes, feel free to open a pull request. Please make sure to follow the existing code style and write tests for any new functionality.

Here's a short summary to get your started with your contributions:

  • Fork and pull the repository
  • Go to the packages/generator and packages/usage folders separately.
  • Inside generator:
    • Run yarn install and yarn dev to start dts in watch mode.
    • Make changes to the source code
  • Inside usage:
    • Make some modifications to the prisma/schema.prisma schema.
    • Run yarn prisma generate and check the output in types/*.

Done! Once you've got some changes, create a pull request and I'll try my best to review and merge them quickly!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Shoutouts

  • This generator would not have been possible without the great efforts made by the go-jet team! The generator they have built into go-jet is awesome, however it lacks the contextual information that Prisma can provide. It makes perfect sense to use Prisma to migrate your database, then use the built-in generator from go-jet to create your types, but I wanted to eliminate the extra step and instead do everything in one go, hence this generator was made.
  • The amazing prisma-ast parser, which allows this generator to extract additional data, otherwise unavailable in the Prisma DMMF representation of the schema. Go give it a star!
  • Lots of inspiration from other generators, such as prisma-kysely, zod-prisma-types, and more, so thanks for creating awesome generators for Prisma!