odm

package
v0.0.0-...-86833b7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientType = reflect.TypeOf((*mongo.Client)(nil))
View Source
var CollectionType = reflect.TypeOf((*mongo.Collection)(nil))
View Source
var DatabaseType = reflect.TypeOf((*mongo.Database)(nil))

Functions

func CurrentClient

func CurrentClient(registry *container.Registry) *mongo.Client

func CurrentCollection

func CurrentCollection(cdi *container.Registry) *mongo.Collection

func CurrentDatabase

func CurrentDatabase(registry *container.Registry) *mongo.Database

func WithCollectionManager

func WithCollectionManager(registry *container.Registry, manager interface{}, collectionName string) error

func WithTraits

func WithTraits(registry *container.Registry, traits ...Trait) error

Types

type Component

type Component struct {
	Database      string
	ClientOptions []*options.ClientOptions
	Client        *mongo.Client
}

func NewComponent

func NewComponent(databaseName string, options ...*options.ClientOptions) *Component

func (*Component) Bootstrap

func (component *Component) Bootstrap(app *app.Kernel)

type Manager

type Manager struct {
	Context    context.Context
	Collection *mongo.Collection
	Registry   *container.Registry
}

func (*Manager) Aggregate

func (m *Manager) Aggregate(pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)

func (*Manager) BulkWrite

func (m *Manager) BulkWrite(models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)

func (*Manager) CountDocuments

func (m *Manager) CountDocuments(filter interface{}, opts ...*options.CountOptions) (int64, error)

func (*Manager) DeleteMany

func (m *Manager) DeleteMany(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*Manager) DeleteOne

func (m *Manager) DeleteOne(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*Manager) Distinct

func (m *Manager) Distinct(fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)

func (*Manager) EnsureIndex

func (m *Manager) EnsureIndex(indexName string, keys primitive.D, unique bool, opts ...*options.CreateIndexesOptions) error

func (*Manager) EstimatedDocumentCount

func (m *Manager) EstimatedDocumentCount(opts ...*options.EstimatedDocumentCountOptions) (int64, error)

func (*Manager) Find

func (m *Manager) Find(filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)

func (*Manager) FindOne

func (m *Manager) FindOne(filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

func (*Manager) FindOneAndDelete

func (m *Manager) FindOneAndDelete(filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult

func (*Manager) FindOneAndReplace

func (m *Manager) FindOneAndReplace(filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult

func (*Manager) FindOneAndUpdate

func (m *Manager) FindOneAndUpdate(filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult

func (*Manager) FindOneByID

func (m *Manager) FindOneByID(id interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

func (*Manager) FindPaged

func (m *Manager) FindPaged(q, sort interface{}, page, size int) (*mongo.Cursor, error)

func (*Manager) FindPagedInto

func (m *Manager) FindPagedInto(q, sort interface{}, page, size int, dest interface{}) error

func (*Manager) InsertMany

func (m *Manager) InsertMany(documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

func (*Manager) InsertOne

func (m *Manager) InsertOne(document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*Manager) ReplaceOne

func (m *Manager) ReplaceOne(filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

func (*Manager) UpdateByID

func (m *Manager) UpdateByID(id interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*Manager) UpdateMany

func (m *Manager) UpdateMany(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*Manager) UpdateOne

func (m *Manager) UpdateOne(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

type Trait

type Trait interface {
	OnFilter(filter interface{}) interface{}
	OnInsert(doc interface{}) interface{}
	OnUpdateOrReplace(filter, doc interface{}) interface{}
	OnDelete(filter interface{}) interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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