betterrest

package module
v0.4.26 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: MIT Imports: 9 Imported by: 0

README

BetterREST

This experimental project aims to allow user to define only database schema to have the basic CRUD functionality provided by a REST interface.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegDB added in v0.4.16

func RegDB(dbi *gorm.DB)

RegDB register the db

func SetConfig added in v0.4.21

func SetConfig(cfg Config)

Types

type Config added in v0.4.21

type Config struct {
	Log bool
}

type Registrar added in v0.4.5

type Registrar struct {
	// contains filtered or unexported fields
}

Registrar has registration methods for models

func For added in v0.4.5

func For(typeString string) *Registrar

For set the current registering typeString

func (*Registrar) BatchCRUPDHooks added in v0.4.5

func (r *Registrar) BatchCRUPDHooks(
	before func(bhpData models.BatchHookPointData, op models.CRUPDOp) error,
	after func(bhpData models.BatchHookPointData, op models.CRUPDOp) error) *Registrar

BatchCRUPDHooks adds hookpoints which are called before CUPD (no read) and after batch CRUPD. Either one can be left as nil

func (*Registrar) BatchCreateHooks added in v0.4.5

func (r *Registrar) BatchCreateHooks(
	before func(bhpData models.BatchHookPointData) error,
	after func(bhpData models.BatchHookPointData) error) *Registrar

BatchCreateHooks adds hookpoints which are called before and after batch update. Either one can be left as nil

func (*Registrar) BatchDeleteHooks added in v0.4.5

func (r *Registrar) BatchDeleteHooks(
	before func(bhpData models.BatchHookPointData) error,
	after func(bhpData models.BatchHookPointData) error) *Registrar

BatchDeleteHooks adds hookpoints which are called before and after batch delete. Either one can be left as nil

func (*Registrar) BatchPatchHooks added in v0.4.5

func (r *Registrar) BatchPatchHooks(
	beforeApply func(bhpData models.BatchHookPointData) error,
	before func(bhpData models.BatchHookPointData) error,
	after func(bhpData models.BatchHookPointData) error) *Registrar

BatchPatchHooks adds hookpoints which are called before and after batch update. Either one can be left as nil

func (*Registrar) BatchReadHooks added in v0.4.5

func (r *Registrar) BatchReadHooks(after func(bhpData models.BatchHookPointData) error) *Registrar

BatchReadHooks adds hookpoints which are called after and read, can be left as nil

func (*Registrar) BatchRenderer added in v0.4.5

func (r *Registrar) BatchRenderer(renderer func(roles []models.UserRole, who models.Who, modelObj []models.IModel) []byte) *Registrar

BatchRenderer register custom batch renderer (do your own output, not necessarily JSON)

func (*Registrar) BatchUpdateHooks added in v0.4.5

func (r *Registrar) BatchUpdateHooks(
	before func(bhpData models.BatchHookPointData) error,
	after func(bhpData models.BatchHookPointData) error) *Registrar

BatchUpdateHooks adds hookpoints which are called before and after batch update. Either one can be left as nil

func (*Registrar) CustomCreate added in v0.4.5

func (r *Registrar) CustomCreate(modelObj models.IModel, f func(db *gorm.DB) (*gorm.DB, error)) *Registrar

CustomCreate register custom create table funtion

func (*Registrar) Model added in v0.4.5

func (r *Registrar) Model(modelObj models.IModel) *Registrar

Model adds a New function for an models.IModel (convenient function of RegModelWithOption)

func (*Registrar) ModelWithOption added in v0.4.5

func (r *Registrar) ModelWithOption(modelObj models.IModel, options models.RegOptions) *Registrar

ModelWithOption adds a New function for an models.IModel

func (*Registrar) UserModel added in v0.4.5

func (r *Registrar) UserModel(modelObj models.IModel) *Registrar

UserModel set the IModel type

Jump to

Keyboard shortcuts

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