dao

package
v0.0.0-...-389a64c Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDefaultDAO

func InitDefaultDAO(dao DAOInterface)

Init the default DAO of application

Types

type DAOInterface

type DAOInterface interface {
	// FindByFilter is the global function to get multiple results from the database, with custom filters and pagination.
	FindByFilter(dest interface{}, ff []FilterFunc, pf *PaginationFilter) (DAOResultsInterface, error)
	// FindBy is the shortcut function of FindByFilter with simple filters
	FindBy(dest interface{}, params map[string]string, pf *PaginationFilter) (DAOResultsInterface, error)
	// FindById is the function to get a single result by its ID
	FindById(dest interface{}, id string) (DAOResultInterface, error)
	// UpdateFromPrevious is the function to update a resource from a previous resource
	UpdateFromPrevious(from interface{}, to interface{}) (DAOResultInterface, error)
	// Create is the function to create a resource
	Create(resource interface{}) (DAOResultInterface, error)
	// DeleteById is the function to delete a resource by its id
	DeleteById(resource interface{}, id string) error
}

DAOInterface is is the interface to implement if you need to have a custom database manager, by default you can use the dao in orm folder.

func GetResourceDAO

func GetResourceDAO(resource interface{}) DAOInterface

Get the DAO of a resource, or the default one if no one is configured

type DAOResultInterface

type DAOResultInterface interface {
	Get() S
}

Interface to get a DAOResultInterface

type DAOResultsInterface

type DAOResultsInterface interface {
	All() SS
	CountTotal() int
}

Interface to get a DAOResultsInterface

type FilterFunc

type FilterFunc func(s *utils.Context) *utils.Context

Type function to create to handle filters, it starts from a Statement and returns the same updated Statement

type GetDAOInterface

type GetDAOInterface interface {
	GetDAO() DAOInterface
}

Interface to implement in the resource when you want to use a custom DAO

type PaginationFilter

type PaginationFilter struct {
	Limit  int
	Offset int
}

Pagination filter is a model to use to handle pagination results

type S

type S interface{}

Interface of a single results

type SS

type SS []interface{}

Interface of a multiple results

Jump to

Keyboard shortcuts

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