mongo

package
v0.0.0-...-b8189d2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParamMustPairs = errors.New("fieldValues must be even")

Functions

func RawCollection

func RawCollection(collectionName string, opts ...CollectionOption) *mongo.Collection

func RegisterConnection

func RegisterConnection(configs *MongoClient)

func SelectDB

func SelectDB(dbName string) *mongo.Database

Types

type CollectionOption

type CollectionOption func(opt *options)

func WithCollectionOptions

func WithCollectionOptions(mongoCollectionOptions []*mongoOption.CollectionOptions) CollectionOption

func WithDBName

func WithDBName(dbName string) CollectionOption

type Find

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

func Finder

func Finder(collection string, opts ...CollectionOption) *Find

func (*Find) Between

func (f *Find) Between(key string, start, end any) *Find

func (*Find) Contain

func (f *Find) Contain(field string, key string) *Find

func (*Find) CountDocuments

func (f *Find) CountDocuments(ctx context.Context, fieldValues ...any) (int64, error)

func (*Find) Find

func (f *Find) Find(ctx context.Context, page, size int64, fieldValues ...any) result

func (*Find) FindOne

func (f *Find) FindOne(ctx context.Context, fieldValues ...any) result

func (*Find) Gt

func (f *Find) Gt(key string, value any) *Find

func (*Find) Gte

func (f *Find) Gte(key string, value any) *Find

func (*Find) Id

func (f *Find) Id(id any) *Find

func (*Find) In

func (f *Find) In(key string, values ...any) *Find

func (*Find) Lt

func (f *Find) Lt(key string, value any) *Find

func (*Find) Lte

func (f *Find) Lte(key string, value any) *Find

func (*Find) Ne

func (f *Find) Ne(field string, value any) *Find

func (*Find) NotIn

func (f *Find) NotIn(key string, values ...any) *Find

func (*Find) Or

func (f *Find) Or(conditions ...bson.D) *Find

func (*Find) Ors

func (f *Find) Ors(fieldValues ...any) *Find

func (*Find) Regex

func (f *Find) Regex(field string, pattern string) *Find

func (*Find) WithCountOptions

func (f *Find) WithCountOptions(opts ...*mongoOptions.CountOptions) *Find

func (*Find) WithField

func (f *Find) WithField(fields ...string) *Find

func (*Find) WithOneOptions

func (f *Find) WithOneOptions(opts ...*mongoOptions.FindOneOptions) *Find

func (*Find) WithOptions

func (f *Find) WithOptions(opts ...*mongoOptions.FindOptions) *Find

func (*Find) WithReplaceOptions

func (f *Find) WithReplaceOptions(opts ...*mongoOptions.FindOneAndReplaceOptions) *Find

func (*Find) WithSort

func (f *Find) WithSort(sortPairs ...interface{}) *Find

func (*Find) WithUpdateOptions

func (f *Find) WithUpdateOptions(opts ...*mongoOptions.FindOneAndUpdateOptions) *Find

type Insert

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

func Inserter

func Inserter(collection string, opts ...CollectionOption) *Insert

func (*Insert) Insert

func (i *Insert) Insert(ctx context.Context, documents ...interface{}) result

func (*Insert) WithInsertManyOptions

func (i *Insert) WithInsertManyOptions(opts ...*mongoOptions.InsertManyOptions)

func (*Insert) WithInsertOneOptions

func (i *Insert) WithInsertOneOptions(opts ...*mongoOptions.InsertOneOptions)

type MongoClient

type MongoClient struct {
	Path        string `yaml:"path"`
	Username    string `yaml:"username"`
	Password    string `yaml:"password"`
	MaxPoolSize int    `yaml:"max_pool_size"`
	MinPoolSize int    `yaml:"min_pool_size"`
	Database    string `yaml:"database"`
	// contains filtered or unexported fields
}

type Update

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

func Updater

func Updater(collection string, opts ...CollectionOption) *Update

func (*Update) ReplaceOne

func (u *Update) ReplaceOne(ctx context.Context, data any) updateResultInterface

func (*Update) UpdateOne

func (u *Update) UpdateOne(ctx context.Context, fieldValues ...any) updateResultInterface

func (*Update) WithEqFilter

func (u *Update) WithEqFilter(pairs ...any) *Update

func (*Update) WithReplaceOptions

func (u *Update) WithReplaceOptions(opts ...*mongoOptions.ReplaceOptions) *Update

func (*Update) WithUpdateOptions

func (u *Update) WithUpdateOptions(opts ...*mongoOptions.UpdateOptions) *Update

Jump to

Keyboard shortcuts

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