mongo_driver

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 11 Imported by: 0

README

mongo-driver-v2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIndex

func CreateIndex(c *mongo.Collection, opts ...*IndexOption) error

func CursorList

func CursorList(c *mongo.Collection, opt *ListOption) (cursor *mongo.Cursor, err error)

func List

func List(c *mongo.Collection, opt *ListOption, results interface{}) error

func RemoveIndex

func RemoveIndex(c *mongo.Collection, indexNames ...string) error

func RemoveIndexByOption

func RemoveIndexByOption(c *mongo.Collection, opts ...*IndexOption) error

Types

type IndexOption

type IndexOption struct {
	Name string
	//Keys   map[string]interface{}
	Keys   bson.D
	Unique bool
}

type ListOption

type ListOption struct {
	Filter     interface{}
	Sorter     interface{}
	Projection interface{}
	Limit      int64
	Skip       int64
}

type MongoDriver

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

func NewMongoDriver

func NewMongoDriver(opts MongoDriverOptions) (*MongoDriver, error)

func (*MongoDriver) DeleteFile

func (d *MongoDriver) DeleteFile(gridfsBucketName, fileID string) error

func (*MongoDriver) DownloadFile

func (d *MongoDriver) DownloadFile(gridfsBucketName, fileID string) (fileInfo *gridfs.File, fileContent []byte, err error)

func (*MongoDriver) GetCollection

func (d *MongoDriver) GetCollection(name string) *mongo.Collection

func (*MongoDriver) GetFileDownloadStream

func (d *MongoDriver) GetFileDownloadStream(gridfsBucketName, fileID string) (stream *gridfs.DownloadStream, err error)

func (*MongoDriver) GetGridfsBucket

func (d *MongoDriver) GetGridfsBucket(name string) (bucket *gridfs.Bucket, err error)

func (*MongoDriver) UploadFile

func (d *MongoDriver) UploadFile(gridfsBucketName, fileID, fileName string, fileContent []byte) error

type MongoDriverOptions

type MongoDriverOptions struct {
	Database   string
	Host       string
	Port       int
	Username   string
	Password   string
	AuthSource string
}

Jump to

Keyboard shortcuts

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