Work in progress!
Generates a basic repository by db model definition.
Expected to be used by goqu and sqlx users.
TODO: list and describe generated structs and methods.
Generator creates a repository definition file containing the main CRUD methods:
Create
Get
Update
Delete
,DeleteMany
... and some special methods:
WithTran
currently must be used for wrapping each repo method call.each
,iter
for user future use in custom repo methods.
$ go get github.com/funvit/goqu-crud-gen/cmd/...
Define a db-model.
Rules:
- model must have one field marked as primary key via adding option
primary
for tagdb
- supported field types:
- standard (
int64
,string
...) - any other which implements
Scanner
andValuer
interfaces (ex: github.com/google/uuid)
- standard (
- supported field types:
- if model primary key field value is database-side generated
int64
- useauto
option for tagdb
- generated file will be placed near model definition
See examples for mode info.
See ./examples folder.
- tests
- tests with mysql in docker
- string field maxlen rule by annotation?
-
new flag allowed customising(WithTran
method name.-rename-with-tran
)