mongodb

package
v0.0.0-...-298ae05 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallBack

type CallBack func(*mongo.Cursor) error

type CursorF

type CursorF func(*mongo.Cursor) error

type DB

type DB interface {
	Init(ctx context.Context, option ...Option) (err error)
	Insert(coll string, instance interface{}) (id string, err error)
	Find(coll string, filter interface{}, callback CallBack, skip int64, limit int64, sort int) error
	FindOne(coll string, filter interface{}, result interface{}) (err error)
	Delete(coll string, filter interface{}) (err error)
	Update(coll string, filter, update interface{}) (err error)
	Count(coll string, filter interface{}) (num int64, err error)
	Aggregation(coll string, pipe interface{}, cursorF interface{}) (err error) // 聚合查询
}

数据库

func NewDB

func NewDB(driver string) (db DB)

type Option

type Option func(opts *Options)

func WithAddr

func WithAddr(addr string) Option

func WithCollIndex

func WithCollIndex(ci map[string]string) Option

集合索引

func WithDB

func WithDB(db string) Option

func WithDatabase

func WithDatabase(db string) Option

func WithPwd

func WithPwd(pwd string) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithUsername

func WithUsername(user string) Option

type Options

type Options struct {
	Addr      string
	Username  string
	Password  string
	Timeout   time.Duration
	Database  string
	CollIndex map[string]string
}

func DefaultOpts

func DefaultOpts() *Options

type Store

type Store interface {
	Init(ctx context.Context, option ...Option) (err error)
	Upload(name string, source io.Reader) (id string, err error)
	Download(id interface{}, stream io.Writer) (size int64, err error)
	FindFile(filter interface{}, cursorF interface{}, skip, limit int32) (err error)
	DeleteFile(id interface{}) (err error)
}

存储

func NewStore

func NewStore(driver string) (store Store)

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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