odm

package
v0.1.46 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClient added in v0.1.5

func GetClient() *mongo.Client

Types

type BootRepository added in v0.1.35

type BootRepository[T any] interface {
	Save(model DbModel) chan error
	FindOneById(id string) (chan *T, chan error)
	IsExistsById(id string) bool
	CountDocuments(filters bson.M) (chan int64, chan error)
	Distinct(fieldName string, filters bson.D, serverMaxTime time.Duration) (chan []interface{}, chan error)
	FindOne(filters bson.M) (chan *T, chan error)
	Find(filters bson.M, sort bson.D, limit, skip int64) (chan []T, chan error)
	DeleteById(id string) chan error
	DeleteOne(filters bson.M) chan error
	GetModel(proto interface{}) *T
	Aggregate(pipeline mongo.Pipeline) (chan []T, chan error)
}

type CollectionInterface added in v0.1.41

type CollectionInterface interface {
	UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
	Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (cur *mongo.Cursor, err error)
	DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
	CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
	Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
}

type Config added in v0.1.41

type Config struct {
	Database       string
	CollectionName string
	Client         *mongo.Client
}

func NewConfig added in v0.1.41

func NewConfig(options ...Option) *Config

type DbModel

type DbModel interface {
	Id() string
}

type DefaultTimer added in v0.1.41

type DefaultTimer struct{}

func (DefaultTimer) Now added in v0.1.41

func (d DefaultTimer) Now() int64

type Option added in v0.1.41

type Option func(*Config)

func WithClient added in v0.1.41

func WithClient(client *mongo.Client) Option

func WithCollectionName added in v0.1.41

func WithCollectionName(collectionName string) Option

func WithDatabase added in v0.1.41

func WithDatabase(database string) Option

type Timer added in v0.1.41

type Timer interface {
	Now() int64
}

type UnimplementedBootRepository added in v0.1.35

type UnimplementedBootRepository[T any] struct {
	// contains filtered or unexported fields
}

func NewUnimplementedBootRepository added in v0.1.41

func NewUnimplementedBootRepository[T any](options ...Option) UnimplementedBootRepository[T]

func (*UnimplementedBootRepository[T]) Aggregate added in v0.1.35

func (r *UnimplementedBootRepository[T]) Aggregate(pipeline mongo.Pipeline) (chan []T, chan error)

func (*UnimplementedBootRepository[T]) CountDocuments added in v0.1.35

func (r *UnimplementedBootRepository[T]) CountDocuments(filters bson.M) (chan int64, chan error)

Finds documents count on filters.

func (*UnimplementedBootRepository[T]) DeleteById added in v0.1.35

func (r *UnimplementedBootRepository[T]) DeleteById(id string) chan error

func (*UnimplementedBootRepository[T]) DeleteOne added in v0.1.35

func (r *UnimplementedBootRepository[T]) DeleteOne(filters bson.M) chan error

func (*UnimplementedBootRepository[T]) Distinct added in v0.1.35

func (r *UnimplementedBootRepository[T]) Distinct(fieldName string, filters bson.D, serverMaxTime time.Duration) (chan []interface{}, chan error)

Finds all unique values for a field

func (*UnimplementedBootRepository[T]) Find added in v0.1.35

func (r *UnimplementedBootRepository[T]) Find(filters bson.M, sort bson.D, limit, skip int64) (chan []T, chan error)

func (*UnimplementedBootRepository[T]) FindOne added in v0.1.35

func (r *UnimplementedBootRepository[T]) FindOne(filters bson.M) (chan *T, chan error)

Finds one object based on filters.

func (*UnimplementedBootRepository[T]) FindOneById added in v0.1.35

func (r *UnimplementedBootRepository[T]) FindOneById(id string) (chan *T, chan error)

Finds one object based on Id.

func (*UnimplementedBootRepository[T]) GetModel added in v0.1.35

func (r *UnimplementedBootRepository[T]) GetModel(proto interface{}) *T

Gets an instance of model from proto or othe object.

func (*UnimplementedBootRepository[T]) IsExistsById added in v0.1.35

func (r *UnimplementedBootRepository[T]) IsExistsById(id string) bool

checks if a record exists by id. Synchronous becuase it is expected to be very light-weighted without deserialization etc.

func (*UnimplementedBootRepository[T]) Save added in v0.1.35

func (r *UnimplementedBootRepository[T]) Save(model DbModel) chan error

Jump to

Keyboard shortcuts

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