database

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: LGPL-3.0 Imports: 8 Imported by: 0

README

What does this directory DO?

This package provides basic database handlers for a testing mock database (PLEASE don't use in prod!) and a MongoDB handler. The database.go file also defines DatabaseAccessor which can be extended upon for custom implementations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseAccessor

type DatabaseAccessor interface {
	InsertOne(table string, body map[string]interface{}) (interface{}, error)
	UpdateOne(table string, query map[string]interface{}, body map[DatabaseUpdateActions]map[string]interface{}) (interface{}, error)
	FindOne(table string, query map[string]interface{}) (interface{}, bool)
	Find(table string, query map[string]interface{}) ([]interface{}, bool)
	DeleteOne(table string, query map[string]interface{}) (bool, error)
	Drop(table string) error
}

type DatabaseUpdateActions

type DatabaseUpdateActions string
const (
	SET  DatabaseUpdateActions = "set"
	PUSH DatabaseUpdateActions = "push"
)

type MongoDatabase

type MongoDatabase struct {
	Ctx    context.Context
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

func (MongoDatabase) DeleteOne

func (db MongoDatabase) DeleteOne(table string, query map[string]interface{}) (bool, error)

func (MongoDatabase) Drop added in v0.2.3

func (db MongoDatabase) Drop(table string) error

func (MongoDatabase) Find

func (db MongoDatabase) Find(table string, query map[string]interface{}) ([]interface{}, bool)

func (MongoDatabase) FindOne

func (db MongoDatabase) FindOne(table string, query map[string]interface{}) (interface{}, bool)

func (*MongoDatabase) Initialize

func (db *MongoDatabase) Initialize(uri string, database string) error

func (MongoDatabase) InsertOne

func (db MongoDatabase) InsertOne(table string, body map[string]interface{}) (interface{}, error)

func (MongoDatabase) UpdateOne

func (db MongoDatabase) UpdateOne(table string, query map[string]interface{}, body map[DatabaseUpdateActions]map[string]interface{}) (interface{}, error)

type TestDatabase

type TestDatabase struct {
	Tables map[string]map[string]interface{}
}

func (TestDatabase) DeleteOne

func (db TestDatabase) DeleteOne(table string, query map[string]interface{}) (bool, error)

func (TestDatabase) Drop added in v0.2.3

func (db TestDatabase) Drop(table string) error

func (TestDatabase) Find

func (db TestDatabase) Find(table string, query map[string]interface{}) ([]interface{}, bool)

func (TestDatabase) FindOne

func (db TestDatabase) FindOne(table string, query map[string]interface{}) (interface{}, bool)

func (TestDatabase) InsertOne

func (db TestDatabase) InsertOne(table string, body map[string]interface{}) (interface{}, error)

func (TestDatabase) UpdateOne

func (db TestDatabase) UpdateOne(table string, query map[string]interface{}, body map[DatabaseUpdateActions]map[string]interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

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