Skip to content

LdDl/bungen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bungen - cli tool for generating Bun [Postgres driver] models

Go Report Card

About:

  • This tool has been adapted from Genna - https://github.com/dizzyfool/genna which has been made for go-pg package. I think it will be cool to have same CLI but for Bun which is new evolution of go-pg

  • Although this CLI is targeted for Bun, you should be aware that it's still compatible with Postgres only.

  • I've done a lot of plain code replacements: current tests are fine, but I haven't managed cases with multiple FK's, composite FK's. I do know that this tool needs to manage DEFAULT values e.g. default:'SOME DEFAULT FUNCTION' also, but this needs more affort (pull requests are welcome).

Requirements:

  • bun
  • your PostgreSQL database

Idea

In most of the cases Bun [Postgres driver] models represent database's tables and relations. Bungen's main goal is to prepare those models by reading detailed information about PostrgeSQL database. The result should be several files with ready to use structs with Bun ORM package.

Usage

  1. Install go get github.com/LdDl/bungen && go install github.com/LdDl/bungen@latest
  2. Read though help bungen -h

Currently bungen support 3 generators:

  • model, that generates basic Bun [Postgres driver] model (with provided -q and -z flags it is possible to create simple SELECT * functions)
  • model-named, same as basic but with named structs for columns and tables (author: @Dionid)
  • search, that generates search structs for basic model
  • validation, that generates validate functions for basic model

Examples located in each generator

Thanks

  • I am thankful to Genna and its creator @dizzyfool. Its contributors should be mentioned also. This CLI saved a lot of time for me in the past.
  • Big shoutouts to Bun creators for great ORM package for Golang

About

Model generator for bun package

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.9%
  • Makefile 0.1%