/gormgen

generates go code to access (postgre)sql database

Primary LanguageGo

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...