bungen

command module
v0.0.0-...-70569e3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 1 Imported by: 0

README

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

Forked from: https://github.com/ant31/bungen

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/ant31/bungen && go install github.com/ant31/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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
generators

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL