Skip to content
/ cruder Public

Generate code for CRUD functions from a Go struct

License

Notifications You must be signed in to change notification settings

pengux/cruder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cruder

Generate code for CRUD functions from a Go struct

Go Report Card

Usage

cruder is a tool to generate code for Create, Read, Update, Delete functions
from a Go struct. It supports multiple generators which currently are:

Functions that can be generated are:
- Create: Adds an entry
- Read: Gets an entry using an ID
- List: Gets multiple entries
- Update: Updates an entry
- Delete: Deletes an entry using an ID

Usage:
  cruder [command]

Available Commands:
  help        Help about any command
  pg          Generates CRUD methods for Postgresql, uses the lib/pg package

Flags:
      --fn stringArray           CRUD functions to generate, e.g. --fn "create" --fn "delete". Default to all functions (default [create,get,list,update,delete])
  -h, --help                     help for cruder
      --pkg string               package name for the generated code, default to the same package from input
      --primaryfield string      the field to use as primary key. Default to 'ID' if it exists in the <struct>
      --readfield stringArray    Fields in the struct that should be used for read operations (get,list). Default to all fields except the one used for softdelete
      --skipsuffix               Skip adding the struct name as suffix to the generated functions
      --softdeletefield string   the field to use for softdelete (should be of type nullable datetime field). Default to 'DeletedAt' if it exists in the <struct>
      --writefield stringArray   Fields in the struct that should be used for write operations (create,update). Default to all fields

Use "cruder [command] --help" for more information about a command.

Example

cruder --table=foos Foo example/example.go

About

Generate code for CRUD functions from a Go struct

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages