mongobrocker

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 16 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 NewClient

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

func NewClientWithTLS

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

Types

type ChangeStream

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

ChangeStream define what to watch? client, database or collection

func NewChangeStream

func NewChangeStream() *ChangeStream

NewChangeStream get a new ChangeStream

func (*ChangeStream) SetCollection

func (cs *ChangeStream) SetCollection(collection string)

SetCollection se collection

func (*ChangeStream) SetDatabase

func (cs *ChangeStream) SetDatabase(database string)

SetDatabase set database

func (*ChangeStream) SetPipeline

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

SetPipeline set pipeline

func (*ChangeStream) Watch

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

Watch print oplog in JSON format

type Client

type Client struct {
	*broker.BaseComponent
	RealCli *mongo.Client
}

func (*Client) Aggregate

func (c *Client) Aggregate(ctx context.Context, dbName, collName string, pipeline mongo.Pipeline) (*mongo.Cursor, error)

func (*Client) BulkWrite

func (c *Client) BulkWrite(ctx context.Context, dbName, collName string, models []mongo.WriteModel, opts *options.BulkWriteOptions) (*mongo.BulkWriteResult, error)

func (*Client) ChangeStreamClient

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

func (*Client) ChangeStreamCollection

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

func (*Client) ChangeStreamDB

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

func (*Client) Count

func (c *Client) Count(ctx context.Context, dbName, collName string, filter interface{}) (int64, error)

func (*Client) CountDocuments

func (c *Client) CountDocuments(ctx context.Context, dbName, collName string, filter interface{}) (int64, error)

CountDocuments You can get an exact number of documents in a collection

func (*Client) CreateIndex

func (c *Client) CreateIndex(ctx context.Context, dbName, collName string, indexModel mongo.IndexModel) (string, error)

func (*Client) DeleteMany

func (c *Client) DeleteMany(ctx context.Context, dbName, collName string, filter interface{}) (*mongo.DeleteResult, error)

func (*Client) DeleteOne

func (c *Client) DeleteOne(ctx context.Context, dbName, collName string, filter interface{}) (*mongo.DeleteResult, error)

func (*Client) Distinct

func (c *Client) Distinct(ctx context.Context, dbName, collName string, fieldName string, filter interface{}) ([]interface{}, error)

func (*Client) DownLoadGridFS

func (c *Client) DownLoadGridFS(ctx context.Context, fileID interface{}, db *mongo.Database, bucketOptions *options.BucketOptions) (string, error)

DownLoadGridFS ...

func (*Client) DropIndex

func (c *Client) DropIndex(ctx context.Context, dbName, collName string, indexName string) (bson.Raw, error)

func (*Client) EstimatedDocumentCount

func (c *Client) EstimatedDocumentCount(ctx context.Context, dbName, collName string) (int64, error)

EstimatedDocumentCount You can get an approximation on the number of documents in a collection

func (*Client) Find

func (c *Client) Find(ctx context.Context, dbName, collName string, filter interface{}) (*mongo.Cursor, error)

func (*Client) FindOne

func (c *Client) FindOne(ctx context.Context, dbName, collName string, filter interface{}) *mongo.SingleResult

func (*Client) FindWithOption

func (c *Client) FindWithOption(ctx context.Context, dbName, collName string, filter interface{},
	findOptions *options.FindOptions) (*mongo.Cursor, error)

func (*Client) InsertMany

func (c *Client) InsertMany(ctx context.Context, dbName, collName string, data []interface{}) (*mongo.InsertManyResult, error)

func (*Client) InsertOne

func (c *Client) InsertOne(ctx context.Context, dbName, collName string, data interface{}) (*mongo.InsertOneResult, error)

func (*Client) ReplaceOne

func (c *Client) ReplaceOne(ctx context.Context, dbName, collName string, filter interface{}, replacement interface{}) (*mongo.UpdateResult, error)

func (*Client) RunCommand

func (c *Client) RunCommand(ctx context.Context, dbName string, command interface{}) (bson.M, error)

func (*Client) UpdateByID

func (c *Client) UpdateByID(ctx context.Context, dbName, collName string, id interface{}, data interface{}) (*mongo.UpdateResult, error)

func (*Client) UpdateByIDWithSession

func (c *Client) UpdateByIDWithSession(ctx context.Context, dbName, collName string, id interface{}, data interface{}) error

func (*Client) UpdateMany

func (c *Client) UpdateMany(ctx context.Context, dbName, collName string, filter interface{}, data interface{}) (*mongo.UpdateResult, error)

func (*Client) UpdateManyWithSession

func (c *Client) UpdateManyWithSession(ctx context.Context, dbName, collName string, filter interface{}, data interface{}) error

func (*Client) UpdateOne

func (c *Client) UpdateOne(ctx context.Context, dbName, collName string, filter interface{}, data interface{}) (*mongo.UpdateResult, error)

func (*Client) UpdateOneWithSession

func (c *Client) UpdateOneWithSession(ctx context.Context, dbName, collName string, filter interface{}, data interface{}) error

func (*Client) UploadGridFS

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

UploadGridFS ...

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