pmongo

package
v0.0.0-...-da5174d Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

func NewBucket

func NewBucket(b *gridfs.Bucket) *Bucket

func (*Bucket) Delete

func (b *Bucket) Delete(fileID interface{}) error

func (*Bucket) DownloadToStream

func (b *Bucket) DownloadToStream(fileID interface{}, stream io.Writer) (int64, error)

func (*Bucket) DownloadToStreamByName

func (b *Bucket) DownloadToStreamByName(filename string, stream io.Writer, opts ...*options.NameOptions) (int64, error)

func (*Bucket) Drop

func (b *Bucket) Drop() error

func (*Bucket) Find

func (b *Bucket) Find(filter interface{}, opts ...*options.GridFSFindOptions) (CursorInterface, error)

func (*Bucket) OpenDownloadStream

func (b *Bucket) OpenDownloadStream(fileID interface{}) (DownloadStreamInterface, error)

func (*Bucket) OpenDownloadStreamByName

func (b *Bucket) OpenDownloadStreamByName(filename string, opts ...*options.NameOptions) (DownloadStreamInterface, error)

func (*Bucket) OpenUploadStream

func (b *Bucket) OpenUploadStream(filename string, opts ...*options.UploadOptions) (UploadStreamInterface, error)

func (*Bucket) OpenUploadStreamWithID

func (b *Bucket) OpenUploadStreamWithID(fileID interface{}, filename string, opts ...*options.UploadOptions) (UploadStreamInterface, error)

func (*Bucket) Rename

func (b *Bucket) Rename(fileID interface{}, newFilename string) error

func (*Bucket) SetReadDeadline

func (b *Bucket) SetReadDeadline(t time.Time) error

func (*Bucket) SetWriteDeadline

func (b *Bucket) SetWriteDeadline(t time.Time) error

func (*Bucket) UploadFromStream

func (b *Bucket) UploadFromStream(filename string, source io.Reader, opts ...*options.UploadOptions) (primitive.ObjectID, error)

func (*Bucket) UploadFromStreamWithID

func (b *Bucket) UploadFromStreamWithID(fileID interface{}, filename string, source io.Reader, opts ...*options.UploadOptions) error

type BucketInterface

type BucketInterface interface {
	Delete(fileID interface{}) error
	DownloadToStream(fileID interface{}, stream io.Writer) (int64, error)
	DownloadToStreamByName(filename string, stream io.Writer, opts ...*options.NameOptions) (int64, error)
	Drop() error
	Find(filter interface{}, opts ...*options.GridFSFindOptions) (CursorInterface, error)
	OpenDownloadStream(fileID interface{}) (DownloadStreamInterface, error)
	OpenDownloadStreamByName(filename string, opts ...*options.NameOptions) (DownloadStreamInterface, error)
	OpenUploadStream(filename string, opts ...*options.UploadOptions) (UploadStreamInterface, error)
	OpenUploadStreamWithID(fileID interface{}, filename string, opts ...*options.UploadOptions) (UploadStreamInterface, error)
	Rename(fileID interface{}, newFilename string) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
	UploadFromStream(filename string, source io.Reader, opts ...*options.UploadOptions) (primitive.ObjectID, error)
	UploadFromStreamWithID(fileID interface{}, filename string, source io.Reader, opts ...*options.UploadOptions) error
}

type Client

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

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

func (*Client) Database

func (c *Client) Database(name string, opts ...*options.DatabaseOptions) DatabaseInterface

func (*Client) Disconnect

func (c *Client) Disconnect(ctx context.Context) error

func (*Client) ListDatabaseNames

func (c *Client) ListDatabaseNames(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) ([]string, error)

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) (mongo.ListDatabasesResult, error)

func (*Client) NumberSessionsInProgress

func (c *Client) NumberSessionsInProgress() int

func (*Client) Ping

func (c *Client) Ping(ctx context.Context, rp *readpref.ReadPref) error

func (*Client) StartSession

func (c *Client) StartSession(opts ...*options.SessionOptions) (SessionInterface, error)

func (*Client) UseSession

func (c *Client) UseSession(ctx context.Context, fn func(mongo.SessionContext) error) error

func (*Client) UseSessionWithOptions

func (c *Client) UseSessionWithOptions(ctx context.Context, opts *options.SessionOptions, fn func(mongo.SessionContext) error) error

func (*Client) Watch

func (c *Client) Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)

type ClientInterface

type ClientInterface interface {
	Connect(ctx context.Context) error
	Database(name string, opts ...*options.DatabaseOptions) DatabaseInterface
	Disconnect(ctx context.Context) error
	ListDatabaseNames(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) ([]string, error)
	ListDatabases(ctx context.Context, filter interface{}, opts ...*options.ListDatabasesOptions) (mongo.ListDatabasesResult, error)
	NumberSessionsInProgress() int
	Ping(ctx context.Context, rp *readpref.ReadPref) error
	StartSession(opts ...*options.SessionOptions) (SessionInterface, error)
	UseSession(ctx context.Context, fn func(mongo.SessionContext) error) error
	UseSessionWithOptions(ctx context.Context, opts *options.SessionOptions, fn func(mongo.SessionContext) error) error
	Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)
}

func NewClient

func NewClient(c *mongo.Client) ClientInterface

type Collection

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

func NewCollection

func NewCollection(coll *mongo.Collection) *Collection

func (*Collection) Aggregate

func (c *Collection) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (CursorInterface, error)

func (*Collection) BulkWrite

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

func (*Collection) Clone

func (*Collection) CountDocuments

func (c *Collection) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)

func (*Collection) Database

func (c *Collection) Database() DatabaseInterface

func (*Collection) DeleteMany

func (c *Collection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*Collection) DeleteOne

func (c *Collection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*Collection) Distinct

func (c *Collection) Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)

func (*Collection) Drop

func (c *Collection) Drop(ctx context.Context) error

func (*Collection) EstimatedDocumentCount

func (c *Collection) EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error)

func (*Collection) Find

func (c *Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (CursorInterface, error)

func (*Collection) FindOne

func (c *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) SingleResultInterface

func (*Collection) FindOneAndDelete

func (c *Collection) FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) SingleResultInterface

func (*Collection) FindOneAndReplace

func (c *Collection) FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) SingleResultInterface

func (*Collection) FindOneAndUpdate

func (c *Collection) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) SingleResultInterface

func (*Collection) Indexes

func (c *Collection) Indexes() IndexViewInterface

func (*Collection) InsertMany

func (c *Collection) InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

func (*Collection) InsertOne

func (c *Collection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*Collection) Name

func (c *Collection) Name() string

func (*Collection) ReplaceOne

func (c *Collection) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

func (*Collection) UpdateMany

func (c *Collection) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*Collection) UpdateOne

func (c *Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*Collection) Watch

func (c *Collection) Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)

type CollectionInterface

type CollectionInterface interface {
	Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (CursorInterface, error)
	BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
	Clone(opts ...*options.CollectionOptions) (CollectionInterface, error)
	CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
	Database() DatabaseInterface
	DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
	Drop(ctx context.Context) error
	EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error)
	Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (CursorInterface, error)
	FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) SingleResultInterface
	FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) SingleResultInterface
	FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) SingleResultInterface
	FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) SingleResultInterface
	Indexes() IndexViewInterface
	InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
	InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
	Name() string
	ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
	UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)
}

type CursorInterface

type CursorInterface interface {
	All(ctx context.Context, results interface{}) error
	Close(ctx context.Context) error
	Decode(val interface{}) error
	Err() error
	ID() int64
	Next(ctx context.Context) bool
	TryNext(ctx context.Context) bool
}

type Database

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

func NewDatabase

func NewDatabase(db *mongo.Database) *Database

func (*Database) Aggregate

func (d *Database) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (CursorInterface, error)

func (*Database) Client

func (d *Database) Client() ClientInterface

func (*Database) Collection

func (d *Database) Collection(name string, opts ...*options.CollectionOptions) CollectionInterface

func (*Database) Drop

func (d *Database) Drop(ctx context.Context) error

func (*Database) ListCollectionNames

func (d *Database) ListCollectionNames(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) ([]string, error)

func (*Database) ListCollections

func (d *Database) ListCollections(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) (CursorInterface, error)

func (*Database) Name

func (d *Database) Name() string

func (*Database) NewBucket

func (d *Database) NewBucket(opts ...*options.BucketOptions) (BucketInterface, error)

func (*Database) ReadConcern

func (d *Database) ReadConcern() *readconcern.ReadConcern

func (*Database) ReadPreference

func (d *Database) ReadPreference() *readpref.ReadPref

func (*Database) RunCommand

func (d *Database) RunCommand(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) SingleResultInterface

func (*Database) RunCommandCursor

func (d *Database) RunCommandCursor(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) (CursorInterface, error)

func (*Database) Watch

func (d *Database) Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)

func (*Database) WriteConcern

func (d *Database) WriteConcern() *writeconcern.WriteConcern

type DatabaseInterface

type DatabaseInterface interface {
	Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (CursorInterface, error)
	Client() ClientInterface
	Collection(name string, opts ...*options.CollectionOptions) CollectionInterface
	Drop(ctx context.Context) error
	ListCollectionNames(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) ([]string, error)
	ListCollections(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) (CursorInterface, error)
	Name() string
	ReadConcern() *readconcern.ReadConcern
	ReadPreference() *readpref.ReadPref
	RunCommand(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) SingleResultInterface
	RunCommandCursor(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) (CursorInterface, error)
	Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)
	WriteConcern() *writeconcern.WriteConcern

	NewBucket(opts ...*options.BucketOptions) (BucketInterface, error)
}

type DownloadStreamInterface

type DownloadStreamInterface interface {
	Close() error
	Read(p []byte) (int, error)
	SetReadDeadline(t time.Time) error
	Skip(skip int64) (int64, error)
}

type IndexView

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

func NewIndexView

func NewIndexView(indexView mongo.IndexView) IndexView

func (IndexView) CreateMany

func (i IndexView) CreateMany(ctx context.Context, models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)

func (IndexView) CreateOne

func (i IndexView) CreateOne(ctx context.Context, model mongo.IndexModel, opts ...*options.CreateIndexesOptions) (string, error)

func (IndexView) DropAll

func (i IndexView) DropAll(ctx context.Context, opts ...*options.DropIndexesOptions) (bson.Raw, error)

func (IndexView) DropOne

func (i IndexView) DropOne(ctx context.Context, name string, opts ...*options.DropIndexesOptions) (bson.Raw, error)

func (IndexView) List

type IndexViewInterface

type IndexViewInterface interface {
	List(ctx context.Context, opts ...*options.ListIndexesOptions) (CursorInterface, error)
	CreateOne(ctx context.Context, model mongo.IndexModel, opts ...*options.CreateIndexesOptions) (string, error)
	CreateMany(ctx context.Context, models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)
	DropOne(ctx context.Context, name string, opts ...*options.DropIndexesOptions) (bson.Raw, error)
	DropAll(ctx context.Context, opts ...*options.DropIndexesOptions) (bson.Raw, error)
}

type SessionInterface

type SessionInterface interface {
	StartTransaction(opts ...*options.TransactionOptions) error
	AbortTransaction(ctx context.Context) error
	CommitTransaction(ctx context.Context) error
	WithTransaction(ctx context.Context, fn func(sessCtx mongo.SessionContext) (interface{}, error),
		opts ...*options.TransactionOptions) (interface{}, error)
	EndSession(ctx context.Context)

	ClusterTime() bson.Raw
	OperationTime() *primitive.Timestamp
	Client() ClientInterface
	ID() bson.Raw

	AdvanceClusterTime(bson.Raw) error
	AdvanceOperationTime(ts *primitive.Timestamp) error
}

type SingleResultInterface

type SingleResultInterface interface {
	Decode(v interface{}) error
	DecodeBytes() (bson.Raw, error)
	Err() error
}

type UploadStreamInterface

type UploadStreamInterface interface {
	Abort() error
	Close() error
	SetWriteDeadline(t time.Time) error
	Write(p []byte) (int, error)
}

Directories

Path Synopsis
Package mock_pmongo is a generated GoMock package.
Package mock_pmongo is a generated GoMock package.

Jump to

Keyboard shortcuts

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