odm

package
v0.1.31 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 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 AbstractRepository

type AbstractRepository[T any] struct {
	Database       string
	CollectionName string
}

func (*AbstractRepository[T]) CountDocuments added in v0.1.22

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

Finds documents count on filters.

func (*AbstractRepository[T]) DeleteById added in v0.1.9

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

func (*AbstractRepository[T]) DeleteOne added in v0.1.9

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

func (*AbstractRepository[T]) Distinct added in v0.1.22

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

Finds all unique values for a field

func (*AbstractRepository[T]) Find

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

func (*AbstractRepository[T]) FindOne

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

Finds one object based on filters.

func (*AbstractRepository[T]) FindOneById

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

Finds one object based on Id.

func (*AbstractRepository[T]) GetModel

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

Gets an instance of model from proto or othe object.

func (*AbstractRepository[T]) IsExistsById added in v0.1.7

func (r *AbstractRepository[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 (*AbstractRepository[T]) Save

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

type DbModel

type DbModel interface {
	Id() string
}

Jump to

Keyboard shortcuts

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