mongoutil

package module
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// fields of the objects in db
	ID        = "_id"
	CreatedAt = "createdAt"
	UpdatedAt = "updatedAt"

	// field used to return lists
	List = "results"
)

Variables

This section is empty.

Functions

func ValidateInput

func ValidateInput(rs requestscope.RequestScope, extras interface{}, req, res messages.Message, db dataprovider.Provider) (editedReq, editedRes messages.Message, editedRs requestscope.RequestScope, err *utils.Error)

Checks body of the request. Returns error if the request body contains any restricted fields. Must be added to POST and PUT requests for all paths. Example Usage: core.Interceptors.Add(interceptors.AnyPath, methods.Post, interceptors.BEFORE_EXEC, mongoutil.ValidateInput, nil) core.Interceptors.Add(interceptors.AnyPath, methods.Put, interceptors.BEFORE_EXEC, mongoutil.ValidateInput, nil)

Types

type DataProvider

type DataProvider struct {
	Addresses    []string
	Database     string
	AuthDatabase string
	Username     string
	Password     string
	Collections  map[string]bool
	// contains filtered or unexported fields
}

func (*DataProvider) Connect

func (ma *DataProvider) Connect() (err *utils.Error)

func (DataProvider) Create

func (ma DataProvider) Create(collection string, data map[string]interface{}) (response map[string]interface{}, err *utils.Error)

func (DataProvider) CreateFile

func (ma DataProvider) CreateFile(data io.ReadCloser) (response map[string]interface{}, err *utils.Error)

func (DataProvider) Delete

func (ma DataProvider) Delete(collection string, id string) (response map[string]interface{}, err *utils.Error)

func (DataProvider) Get

func (ma DataProvider) Get(collection string, id string) (response map[string]interface{}, err *utils.Error)

func (DataProvider) GetFile

func (ma DataProvider) GetFile(id string) (response []byte, err *utils.Error)

func (*DataProvider) Init

func (ma *DataProvider) Init() (err *utils.Error)

func (DataProvider) Query

func (ma DataProvider) Query(collection string, parameters map[string][]string) (response map[string]interface{}, err *utils.Error)

func (DataProvider) Update

func (ma DataProvider) Update(collection string, id string, data map[string]interface{}) (response map[string]interface{}, err *utils.Error)

Jump to

Keyboard shortcuts

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