Skip to content
/ gormgen Public

generates go code to access (postgre)sql database

Notifications You must be signed in to change notification settings

mjolk/gormgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ORMGEN

generates a ton of code to have type safe acces to database and not much fucking around with strings in source code (you can if you want to for these special queries with complex partition or distinct on stuff) supports one to many (many to one) and many to many it's a model first approach , models are json config files mainly postgres but planning on supporting cockroachdb, need to implement embedded relations for that wip: need to make optional some customizations that are now generated by default.

Install

this project is still using jteeuwen's bindata , you can use another lib to embed tmpl files into the binary
just change the go generate in ormgen.go

go generate 
go install

Usage

ormgen [options] paths...

Options

-l
    maximum depth to fetch relations, all levels from 0 to max level will be available
    eg user.friend -> friend is level 1, user.friend.anotherrelation -> anotherrelation is depth 2
    watch out there is no reflection and the generated code is super simple but it amounts to a lot of LOC

-t
    either 'go' to directly generate go structs or 'proto' to generate intermediate protobuf files

-v, -version
    Print version and exit.

-h, -help
    Print help and exit.

TODO example configuration with one to many/many to many cfg (JSON files)

TODO example querying, inserting, updating, using changeset, versioning etc...

About

generates go code to access (postgre)sql database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages