database

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEngineNotSupported = errors.New("database not engine supported")

Functions

func AddEngine

func AddEngine(
	ctx context.Context,
	source *config.Database,
	log logger.Logger,
) error

func GetEngine

func GetEngine[T GlobalExecutor](engine config.Engine) T

Types

type Cursor

type Cursor interface {
	Next(ctx context.Context) bool
	Result() ([]*Result, error)
}

type GlobalExecutor

type GlobalExecutor interface {
	Close() error
}

type Mongo

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

func (*Mongo) AddCollection

func (m *Mongo) AddCollection(col string)

func (*Mongo) Close

func (m *Mongo) Close() error

func (*Mongo) Count

func (m *Mongo) Count(ctx context.Context, col string) (int64, error)

func (*Mongo) FindLimit

func (m *Mongo) FindLimit(ctx context.Context, limit int64, col string) (Cursor, error)

func (*Mongo) FindOne

func (m *Mongo) FindOne(ctx context.Context, filter interface{}, col string) (Result, error)

func (*Mongo) Watcher

func (m *Mongo) Watcher(ctx context.Context, col string) (<-chan func() (wType WatcherType, res WatchResult), error)

type MongoExecutor

type MongoExecutor interface {
	GlobalExecutor

	AddCollection(col string)
	Count(ctx context.Context, col string) (int64, error)
	FindOne(ctx context.Context, filter interface{}, col string) (Result, error)
	FindLimit(ctx context.Context, limit int64, col string) (Cursor, error)
	Watcher(ctx context.Context, col string) (<-chan func() (WatcherType, WatchResult), error)
}

type Result

type Result map[string]interface{}

type SQL added in v0.3.0

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

func (*SQL) Close added in v0.3.0

func (s *SQL) Close() error

func (*SQL) Count added in v0.3.0

func (s *SQL) Count(ctx context.Context, table string) (int64, error)

func (*SQL) FindLimit added in v0.3.0

func (s *SQL) FindLimit(ctx context.Context, table string, limit int64) (Cursor, error)

func (*SQL) FindOne added in v0.3.0

func (s *SQL) FindOne(ctx context.Context, table string, query map[string]interface{}) (Result, error)

type SQLExecutor added in v0.3.0

type SQLExecutor interface {
	GlobalExecutor

	Count(ctx context.Context, table string) (int64, error)
	FindOne(ctx context.Context, table string, query map[string]interface{}) (Result, error)
	FindLimit(ctx context.Context, table string, limit int64) (Cursor, error)
}

type WatchResult

type WatchResult struct {
	DocumentId primitive.ObjectID
	Document   Result
	Update     struct {
		UpdateFields Result
		RemoveFields []string
	}
}

type WatcherType

type WatcherType uint8
const (
	Null WatcherType = iota
	OnInsert
	OnUpdate
	OnDelete
	OnReplace
)

func (WatcherType) String

func (w WatcherType) String() string

Jump to

Keyboard shortcuts

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