definitions

package
v0.0.0-...-ec57482 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(results interface{}, pipeline interface{}, opts ...*options.AggregateOptions) error

func AggregateFirst

func AggregateFirst(model ModelInterface, pipeline interface{}, opts ...*options.AggregateOptions) (bool, error)

func AggregateFirstWithCtx

func AggregateFirstWithCtx(ctx context.Context, result ModelInterface, pipeline interface{}, aggregateOpts ...*options.AggregateOptions) (bool, error)

func AggregateWithCtx

func AggregateWithCtx(ctx context.Context, results interface{}, pipeline interface{}, aggregateOpts ...*options.AggregateOptions) error

func Close

func Close()

func Coll

func Coll(model ModelInterface) *mongo.Collection

func Ctx

func Ctx() context.Context

func Delete

func Delete(model ModelInterface, opts ...*options.DeleteOptions) error

func DeleteMany

func DeleteMany(model ModelInterface, query interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func DeleteManyWithCtx

func DeleteManyWithCtx(ctx context.Context, model ModelInterface, query interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func DeleteOne

func DeleteOne(model ModelInterface, query interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func DeleteOneWithCtx

func DeleteOneWithCtx(ctx context.Context, model ModelInterface, query interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func DeleteWithCtx

func DeleteWithCtx(ctx context.Context, model ModelInterface, opts ...*options.DeleteOptions) error

func FindByObjectID

func FindByObjectID(model ModelInterface, id interface{}, opts ...*options.FindOneOptions) error

func FindByObjectIDWithCtx

func FindByObjectIDWithCtx(ctx context.Context, model ModelInterface, id interface{}, opts ...*options.FindOneOptions) error

func FindByObjectIDs

func FindByObjectIDs(results interface{}, ids interface{}, additionalPipeline ...interface{}) error

func FindMany

func FindMany(results interface{}, query interface{}, opts ...*options.FindOptions) error

func FindManyWithCtx

func FindManyWithCtx(ctx context.Context, results interface{}, query interface{}, opts ...*options.FindOptions) error

func FindOne

func FindOne(model ModelInterface, query interface{}, opts ...*options.FindOneOptions) error

func FindOneWithCtx

func FindOneWithCtx(ctx context.Context, model ModelInterface, query interface{}, opts ...*options.FindOneOptions) error

func GetClient

func GetClient() (*mongo.Client, error)

func GetCollection

func GetCollection(collectionName string) (*mongo.Collection, error)

func GetDatabase

func GetDatabase() (*mongo.Database, error)

func Initialise

func Initialise(cfg Config, opts ...*options.ClientOptions) error

func InsertOne

func InsertOne(model ModelInterface, opts ...*options.InsertOneOptions) error

func InsertOneWithCtx

func InsertOneWithCtx(ctx context.Context, model ModelInterface, opts ...*options.InsertOneOptions) error

func Transaction

func Transaction(fn codegen.TransactionFunc) error

func TransactionWithOptions

func TransactionWithOptions(fn codegen.TransactionFunc, opts *options.SessionOptions) error

func Update

func Update(model ModelInterface, opts ...*options.UpdateOptions) error

func UpdateMany

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

func UpdateManyWithCtx

func UpdateManyWithCtx(ctx context.Context, model ModelInterface, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func UpdateOne

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

func UpdateOneWithCtx

func UpdateOneWithCtx(ctx context.Context, model ModelInterface, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func UpdateWithCtx

func UpdateWithCtx(ctx context.Context, model ModelInterface, opts ...*options.UpdateOptions) error

Types

type Config

type Config struct {
	OperationTimeout time.Duration
	DatabaseName     string

	TxnSessionOptions *options.SessionOptions
}

type ModelInterface

type ModelInterface interface {
	CollectionName() string

	// Field Information
	GetID() interface{}
	SetID(id interface{})

	// Hooks
	Queried() error
	Creating() error
	Created() error
	Saving() error
	Saved() error
	Updating() error
	Updated() error
	Deleting() error
	Deleted() error
}

type ModelQueryMethods

type ModelQueryMethods interface {
	AggregateFirst(pipeline interface{}, opts ...*options.AggregateOptions) (bool, error)
	Find(interface{}, ...*options.FindOneOptions) error
	FindWithCtx(context.Context, interface{}, ...*options.FindOneOptions) error
	FindByObjectID(interface{}, ...*options.FindOneOptions) error
	FindByObjectIDWithCtx(context.Context, interface{}, ...*options.FindOneOptions) error
	Create(...*options.InsertOneOptions) error
	CreateWithCtx(context.Context, ...*options.InsertOneOptions) error
	Update(...*options.UpdateOptions) error
	UpdateWithCtx(context.Context, ...*options.UpdateOptions) error
	Delete(...*options.DeleteOptions) error
	DeleteWithCtx(context.Context, ...*options.DeleteOptions) error
}

Available query methods

Jump to

Keyboard shortcuts

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