gormcrud

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: MIT Imports: 11 Imported by: 1

README

Gormcrud

Motivation for this project is to provide the a Golang module for it can drive all CRUD api of your GORM entities.

Example:

	gormcrud.Map(r, db).
	NewMap("/api/v1/author", []Author{}).Full().
	NewMap("/api/v1/category", []Category{}).Full().
	NewMap("/api/v1/tag", []Tag{}).Full().
	NewMap("/api/v1/note", []Note{}).Full()

full example https://github.com/gopher1980/gormcrud/blob/master/example/main.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(db *gorm.DB, elem interface{}) func(w http.ResponseWriter, r *http.Request, id string)

All is

func Delete

func Delete(db *gorm.DB, new interface{}) func(w http.ResponseWriter, r *http.Request, id string)

Delete is

func Get added in v0.1.0

func Get(db *gorm.DB, elem interface{}) func(w http.ResponseWriter, r *http.Request, id string)

Get is

func Link(db *gorm.DB, root interface{}, op string) func(w http.ResponseWriter, r *http.Request, id string)

Link is

func Page

func Page(db *gorm.DB, elem interface{}) func(w http.ResponseWriter, r *http.Request, id string)

Page is

func Save

func Save(db *gorm.DB, new interface{}) func(w http.ResponseWriter, r *http.Request, id string)

Save is

func WrapGin added in v0.2.0

func WrapGin(f func(http.ResponseWriter, *http.Request, string)) gin.HandlerFunc

WrapF is a helper function for wrapping http.HandlerFunc and returns a Gin middleware.

func WrapMux added in v0.2.0

func WrapMux(f func(http.ResponseWriter, *http.Request, string)) func(http.ResponseWriter, *http.Request)

Types

type ErrorCrud

type ErrorCrud struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
	// contains filtered or unexported fields
}

type LinkStatusCrud

type LinkStatusCrud struct {
	Message     string `json:"message"`
	Status      string `json:"status"`
	Operation   string `json:"operation"`
	CountAfter  int    `json:"count_after"`
	CountBefore int    `json:"count_before"`
}

type MapperGinGormCrud added in v0.2.0

type MapperGinGormCrud struct {
	R        *gin.Engine
	RestBase string
	Db       *gorm.DB
	Entity   interface{}
	Array    interface{}
}

***************************GIN*********************************************

func MapGin added in v0.2.0

func MapGin(engine *gin.Engine, db *gorm.DB) MapperGinGormCrud

func (MapperGinGormCrud) All added in v0.2.0

func (MapperGinGormCrud) Base added in v0.2.0

func (MapperGinGormCrud) Delete added in v0.2.0

func (MapperGinGormCrud) Full added in v0.2.0

func (MapperGinGormCrud) Get added in v0.2.0

func (MapperGinGormCrud) LinkMethod added in v0.2.0

func (g MapperGinGormCrud) LinkMethod() MapperGinGormCrud

func (MapperGinGormCrud) LinkUrl added in v0.2.0

func (MapperGinGormCrud) NewMap added in v0.2.0

func (g MapperGinGormCrud) NewMap(restBase string, entity interface{}, array interface{}) MapperGinGormCrud

func (MapperGinGormCrud) Page added in v0.2.0

func (MapperGinGormCrud) Save added in v0.2.0

type MapperGormCrud added in v0.1.0

type MapperGormCrud struct {
	R        *mux.Router
	RestBase string
	Db       *gorm.DB
	Entity   interface{}
	Array    interface{}
}

func (MapperGormCrud) All added in v0.1.0

func (MapperGormCrud) Base added in v0.1.0

func (g MapperGormCrud) Base() MapperGormCrud

func (MapperGormCrud) Delete added in v0.1.0

func (g MapperGormCrud) Delete() MapperGormCrud

func (MapperGormCrud) Full added in v0.1.0

func (g MapperGormCrud) Full() MapperGormCrud

func (MapperGormCrud) Get added in v0.1.0

func (MapperGormCrud) LinkMethod added in v0.1.0

func (g MapperGormCrud) LinkMethod() MapperGormCrud

func (MapperGormCrud) LinkUrl added in v0.1.0

func (g MapperGormCrud) LinkUrl() MapperGormCrud

func (MapperGormCrud) NewMap added in v0.1.0

func (g MapperGormCrud) NewMap(restBase string, entity interface{}, array interface{}) MapperGormCrud

func (MapperGormCrud) Page added in v0.1.0

func (g MapperGormCrud) Page() MapperGormCrud

func (MapperGormCrud) Save added in v0.1.0

func (g MapperGormCrud) Save() MapperGormCrud

type ValidateDelete

type ValidateDelete interface {
	CrudValidateDelete(db *gorm.DB) error
}

ValidateDelete is

type ValidateSave

type ValidateSave interface {
	CrudValidateSave(db *gorm.DB) error
}

ValidateSave is

Jump to

Keyboard shortcuts

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