entity-gen

command
v0.0.0-...-1f910d1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 11 Imported by: 0

README

Entity Generator

Generate entity/repo from database table

task gen-entity

# or 
rm -rf internal/generated/entity
go run ./tools/entity-gen   

Table Convention

Code generation based assumption that table follow below conventions:

  1. Tables only have a single primary key called id with data type SERIAL or BIGSERIAL
  2. Audit columns (i.e. created_at, updated_at, and deleted_at) are mandatory. Generated entities don't include these columns
  3. Hard delete is not allowed. The select operation doesn't show soft-deleted rows.

Supported data type

The code generation only support below data type:

  • integer --> int
  • bigint --> int64
  • text --> string
  • timestamp --> time.Time

Please add additional data type support at convertToFieldType() function.

Database Transaction

  • Repo check flag to use database transcation and store the error in the context.Context
  • BEGIN should be called before called the operation via dbtxn.Begin()
  • Check the example at clock_svc.go
  • Find the library at dbtxn

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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