xmongo

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

README

docker run -itd --name mongo -p 27017:27017 mongo --auth

--auth:需要密码才能访问容器服务。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeStreamClient

func ChangeStreamClient(client *mongo.Client, coll *mongo.Collection)

func ChangeStreamCollection

func ChangeStreamCollection(client *mongo.Client, coll *mongo.Collection)

func ChangeStreamDB

func ChangeStreamDB(client *mongo.Client, coll *mongo.Collection)

func Count

func Count(coll *mongo.Collection, filter interface{}) (int64, error)

func DeleteMany

func DeleteMany(coll *mongo.Collection, filter interface{}) (*mongo.DeleteResult, error)

func DeleteOne

func DeleteOne(coll *mongo.Collection, filter interface{}) (*mongo.DeleteResult, error)

func Distinct

func Distinct(coll *mongo.Collection, fieldName string, filter interface{}) ([]interface{}, error)

func DownLoadGridFS

func DownLoadGridFS(fileID interface{}, db *mongo.Database, bucketOptions *options.BucketOptions) (string, error)

DownLoadGridFS ...

func Find

func Find(coll *mongo.Collection, filter interface{}) (*mongo.Cursor, error)

func FindOne

func FindOne(coll *mongo.Collection, filter interface{}) *mongo.SingleResult

func FindWithOption

func FindWithOption(coll *mongo.Collection, filter interface{},
	findOptions *options.FindOptions) (*mongo.Cursor, error)

func GetCOll

func GetCOll(client *mongo.Client, dbName, collName string) *mongo.Collection

func InsertMany

func InsertMany(coll *mongo.Collection, data []interface{}) (*mongo.InsertManyResult, error)

func InsertOne

func InsertOne(ctx context.Context, coll *mongo.Collection, data interface{}) (*mongo.InsertOneResult, error)

func NewClient

func NewClient(ctx context.Context, config *Config) *mongo.Client

func NewClientWithTLS

func NewClientWithTLS() (*mongo.Client, error)

func UpdateByID

func UpdateByID(coll *mongo.Collection, id interface{}, data interface{}) (*mongo.UpdateResult, error)

func UpdateByIDWithSession

func UpdateByIDWithSession(client *mongo.Client, coll *mongo.Collection, id interface{}, data interface{}) error

func UpdateMany

func UpdateMany(coll *mongo.Collection, filter interface{}, data interface{}) (*mongo.UpdateResult, error)

func UpdateManyWithSession

func UpdateManyWithSession(client *mongo.Client, coll *mongo.Collection, filter interface{}, data interface{}) error

func UpdateOne

func UpdateOne(coll *mongo.Collection, filter interface{}, data interface{}) (*mongo.UpdateResult, error)

func UpdateOneWithSession

func UpdateOneWithSession(client *mongo.Client, coll *mongo.Collection, filter interface{}, data interface{}) error

func UploadGridFS

func UploadGridFS(filename string, data interface{}, db *mongo.Database, bucketOptions *options.BucketOptions) error

UploadGridFS ...

Types

type ChangeStream

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

ChangeStream defines what to watch? client, database or collection

func NewChangeStream

func NewChangeStream() *ChangeStream

NewChangeStream gets a new ChangeStream

func (*ChangeStream) SetCollection

func (cs *ChangeStream) SetCollection(collection string)

SetCollection sets collection

func (*ChangeStream) SetDatabase

func (cs *ChangeStream) SetDatabase(database string)

SetDatabase sets database

func (*ChangeStream) SetPipeline

func (cs *ChangeStream) SetPipeline(pipeline []bson.D)

SetPipeline sets pipeline

func (*ChangeStream) Watch

func (cs *ChangeStream) Watch(client *mongo.Client, cb callback)

Watch prints oplogs in JSON format

type Client

type Client struct {
	*bromel.BaseComponent
}

type Config

type Config struct {
	URI                      string
	MinPoolSize, MaxPoolSize uint64
}

Jump to

Keyboard shortcuts

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