mongodb

package
v0.0.0-...-be0592b Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Ping() error
	Database() Database
	Collection(collName string) CollectionInterface
	Session() SessionOperation
}

Client client for mongo

type Closer

type Closer interface {
	Close() error
}

Closer close method

type CollectionInterface

type CollectionInterface interface {
	Name() string
	Drop(ctx context.Context) error
	CreateIndex(index Index) error
	DropIndex(indexName string) error
	GetIndexes() (*QueryIndexResult, error)
	Count(ctx context.Context, filter interface{}) (uint64, error)

	DeleteOne(ctx context.Context, filter interface{}, opts *deleteopt.One) (*DeleteResult, error)
	DeleteMany(ctx context.Context, filter interface{}, opts *deleteopt.Many) (*DeleteResult, error)

	Find(ctx context.Context, filter interface{}, opts *findopt.Many, output interface{}) error
	FindOne(ctx context.Context, filter interface{}, opts *findopt.One, output interface{}) error
	FindOneAndModify(ctx context.Context, filter interface{}, update interface{}, opts *findopt.FindAndModify, output interface{}) error

	AggregateOne(ctx context.Context, pipeline interface{}, opts *aggregateopt.One, output interface{}) error

	InsertOne(ctx context.Context, document interface{}, opts *insertopt.One) error
	InsertMany(ctx context.Context, document []interface{}, opts *insertopt.Many) error

	UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts *updateopt.Many) (*UpdateResult, error)
	UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts *updateopt.One) (*UpdateResult, error)

	ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts *replaceopt.One) (*ReplaceOneResult, error)
}

CollectionInterface collection operation methods

type CommonClient

type CommonClient interface {
	OpenCloser
	Client
}

CommonClient single client instance

type Database

type Database interface {
	Drop() error
	Name() string
	HasCollection(collName string) (bool, error)
	DropCollection(collName string) error
	CreateEmptyCollection(collName string) error
	GetCollectionNames() ([]string, error)
}

Database methods

type DeleteResult

type DeleteResult struct {
	// The number of documents that were deleted.
	DeletedCount uint64 `json:"deletedCount"`
}

DeleteResult is a result of an DeleteOne operat

type Index

type Index struct {
	Keys       map[string]int32 `json:"keys"`
	Name       string           `json:"name"`
	Unique     bool             `json:"unique"`
	Background bool             `json:"background"`
}

Index the collection index definition

type IndexResult

type IndexResult struct {
	Namespace string   `json:"ns"`
	Name      string   `json:"name"`
	Key       []string `json:"key"`
}

IndexResult get collection index result

type OpenCloser

type OpenCloser interface {
	Opener
	Closer
}

OpenCloser open and close methods

type Opener

type Opener interface {
	Open() error
}

Opener open method

type QueryIndexResult

type QueryIndexResult struct {
	Indexes []IndexResult
}

QueryIndexResult get the indexex result

type ReplaceOneResult

type ReplaceOneResult struct {
	UpdateResult `json:",inline"`
}

ReplaceOneResult the replace one function result

type Session

type Session interface {
	OpenCloser
	Transaction
}

Session mongodb session operation methods

type SessionOperation

type SessionOperation interface {
	Options() SessionOptions
	Create() Session
}

SessionOperation defines some methods to create a new session

type SessionOptions

type SessionOptions interface {
}

SessionOptions define the SessionOptions maintaince methods

type Transaction

type Transaction interface {
	StartTransaction() error
	AbortTransaction() error
	CommitTransaction() error
	Collection(collName string) CollectionInterface
}

Transaction transaction operation methods

type UpdateResult

type UpdateResult struct {
	MatchedCount  uint64 `json:"matchedCount"`
	UpsertedCount uint64 `json:"upsertedCount"`
	ModifiedCount uint64 `json:"modifiedCount"`
}

UpdateResult is a result of an update operation.

Directories

Path Synopsis
options

Jump to

Keyboard shortcuts

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