gormcrud

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: MIT Imports: 9 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.Mapping(r, "/api/v1/author", db, Author{}, []Author{})
gormcrud.Mapping(r, "/api/v1/category", db, Category{}, []Category{})
gormcrud.Mapping(r, "/api/v1/tag", db, Tag{}, []Tag{})
gormcrud.Mapping(r, "/api/v1/note", db, Note{}, []Note{})

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)

All is

func Delete

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

Delete is

func Get added in v0.1.0

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

Get is

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

Link is

func Page

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

Page is

func Save

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

Save is

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