Documentation ¶
Index ¶
- Constants
- Variables
- func GetObjectIDCounter(objectID primitive.ObjectID) int64
- func IsDuplicate(err error) bool
- func ToSortOption(fields []string) interface{}
- type Auth
- type Collection
- func (m *Collection) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (CursorInterface, error)
- func (m *Collection) BulkWrite(ctx context.Context, models []mongo.WriteModel, ...) (*mongo.BulkWriteResult, error)
- func (m *Collection) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
- func (m *Collection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (m *Collection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (m *Collection) Distinct(ctx context.Context, fieldName string, filter interface{}, ...) ([]interface{}, error)
- func (m *Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (CursorInterface, error)
- func (m *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) SingleResultInterface
- func (m *Collection) FindOneAndDelete(ctx context.Context, filter interface{}, ...) SingleResultInterface
- func (m *Collection) FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, ...) SingleResultInterface
- func (m *Collection) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, ...) SingleResultInterface
- func (m *Collection) Indexes() mongo.IndexView
- func (m *Collection) InsertMany(ctx context.Context, documents []interface{}, ...) (*mongo.InsertManyResult, error)
- func (m *Collection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (m *Collection) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, ...) (*mongo.UpdateResult, error)
- func (m *Collection) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (m *Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type CollectionInterface
- type Cursor
- func (m *Cursor) All(ctx context.Context, results interface{}) error
- func (m *Cursor) Close(ctx context.Context) error
- func (m *Cursor) Decode(val interface{}) error
- func (m *Cursor) Err() error
- func (m *Cursor) ID() int64
- func (m *Cursor) Next(ctx context.Context) bool
- func (m *Cursor) TryNext(ctx context.Context) bool
- type CursorInterface
- type DSN
- type Host
- type Option
- type Options
- type SingleResult
- type SingleResultInterface
- type Source
- type SourceInterface
Constants ¶
View Source
const (
CodeDuplicateKeyErrorCollection = 11000
)
Variables ¶
View Source
var ( ErrorSessionNotInit = errors.New("database session not init") ErrorDatabaseNotFound = errors.New("database name not found in DSN connection string") )
View Source
var ( ErrorProtocolNotFound = errors.New("protocol not found") ErrorHostsNotFound = errors.New("hosts not found") )
Functions ¶
func GetObjectIDCounter ¶
func IsDuplicate ¶
func ToSortOption ¶
func ToSortOption(fields []string) interface{}
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func (*Collection) Aggregate ¶
func (m *Collection) Aggregate( ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions, ) (CursorInterface, error)
func (*Collection) BulkWrite ¶
func (m *Collection) BulkWrite( ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions, ) (*mongo.BulkWriteResult, error)
func (*Collection) CountDocuments ¶
func (m *Collection) CountDocuments( ctx context.Context, filter interface{}, opts ...*options.CountOptions, ) (int64, error)
func (*Collection) DeleteMany ¶
func (m *Collection) DeleteMany( ctx context.Context, filter interface{}, opts ...*options.DeleteOptions, ) (*mongo.DeleteResult, error)
func (*Collection) DeleteOne ¶
func (m *Collection) DeleteOne( ctx context.Context, filter interface{}, opts ...*options.DeleteOptions, ) (*mongo.DeleteResult, error)
func (*Collection) Distinct ¶
func (m *Collection) Distinct( ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions, ) ([]interface{}, error)
func (*Collection) Find ¶
func (m *Collection) Find( ctx context.Context, filter interface{}, opts ...*options.FindOptions, ) (CursorInterface, error)
func (*Collection) FindOne ¶
func (m *Collection) FindOne( ctx context.Context, filter interface{}, opts ...*options.FindOneOptions, ) SingleResultInterface
func (*Collection) FindOneAndDelete ¶
func (m *Collection) FindOneAndDelete( ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions, ) SingleResultInterface
func (*Collection) FindOneAndReplace ¶
func (m *Collection) FindOneAndReplace( ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions, ) SingleResultInterface
func (*Collection) FindOneAndUpdate ¶
func (m *Collection) FindOneAndUpdate( ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions, ) SingleResultInterface
func (*Collection) Indexes ¶
func (m *Collection) Indexes() mongo.IndexView
func (*Collection) InsertMany ¶
func (m *Collection) InsertMany( ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions, ) (*mongo.InsertManyResult, error)
func (*Collection) InsertOne ¶
func (m *Collection) InsertOne( ctx context.Context, document interface{}, opts ...*options.InsertOneOptions, ) (*mongo.InsertOneResult, error)
func (*Collection) ReplaceOne ¶
func (m *Collection) ReplaceOne( ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions, ) (*mongo.UpdateResult, error)
func (*Collection) UpdateMany ¶
func (m *Collection) UpdateMany( ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions, ) (*mongo.UpdateResult, error)
func (*Collection) UpdateOne ¶
func (m *Collection) UpdateOne( ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions, ) (*mongo.UpdateResult, error)
type CollectionInterface ¶
type CollectionInterface interface { Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (CursorInterface, error) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error) 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) 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 InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) 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) BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error) Indexes() mongo.IndexView }
type CursorInterface ¶
type DSN ¶
type Options ¶
type SingleResult ¶
type SingleResult struct {
// contains filtered or unexported fields
}
func (*SingleResult) Decode ¶
func (m *SingleResult) Decode(v interface{}) error
func (*SingleResult) DecodeBytes ¶
func (m *SingleResult) DecodeBytes() (bson.Raw, error)
func (*SingleResult) Err ¶
func (m *SingleResult) Err() error
type SingleResultInterface ¶
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
func (*Source) Collection ¶
func (s *Source) Collection(name string) CollectionInterface
type SourceInterface ¶
type SourceInterface interface { Close() error Ping(ctx context.Context) error Drop() error Collection(name string) CollectionInterface }
func NewDatabase ¶
func NewDatabase(options ...Option) (SourceInterface, error)
Click to show internal directories.
Click to hide internal directories.