mongodb

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IMongoDbDatabaseObject

type IMongoDbDatabaseObject interface {
	GetUpdatedAt() time.Time
	SetUpdatedAt(time time.Time)
	GetCreatedAt() time.Time
	SetCreatedAt(time time.Time)
	GetIsActive() bool
	SetIsActive(isActive bool)
}

type IMongoDbRepository

type IMongoDbRepository[T IMongoDbDatabaseObject] interface {
	Create(entity T, collectionName string) (*T, error)
	Count(filters interface{}, options *options.CountOptions, collectionName string) (int64, error)
	Get(filters interface{}, options *options.FindOneOptions, collectionName string) (*T, error)
	GetList(filters interface{}, options *options.FindOptions, collectionName string) ([]*T, error)
	Update(filters interface{}, entity *T, collectionName string) (*T, error)
	Remove(filters interface{}, collectionName string) error
}

type MongoDbDatabaseObject

type MongoDbDatabaseObject struct {
	Section   primitive.ObjectID
	UpdatedAt time.Time
	CreatedAt time.Time
	IsActive  bool
}

func (*MongoDbDatabaseObject) GetCreatedAt

func (do *MongoDbDatabaseObject) GetCreatedAt() time.Time

func (*MongoDbDatabaseObject) GetIsActive

func (do *MongoDbDatabaseObject) GetIsActive() bool

func (*MongoDbDatabaseObject) GetUpdatedAt

func (do *MongoDbDatabaseObject) GetUpdatedAt() time.Time

func (*MongoDbDatabaseObject) SetCreatedAt

func (do *MongoDbDatabaseObject) SetCreatedAt(time time.Time)

func (*MongoDbDatabaseObject) SetIsActive

func (do *MongoDbDatabaseObject) SetIsActive(isActive bool)

func (*MongoDbDatabaseObject) SetUpdatedAt

func (do *MongoDbDatabaseObject) SetUpdatedAt(time time.Time)

type MongoDbRepository

type MongoDbRepository[T IMongoDbDatabaseObject] struct {
	DatabaseName string
	// contains filtered or unexported fields
}

func NewMongoDbRepository

func NewMongoDbRepository[T IMongoDbDatabaseObject](client *mongo.Client, databaseName string) *MongoDbRepository[T]

func (*MongoDbRepository[T]) Count

func (r *MongoDbRepository[T]) Count(filters interface{}, options *options.CountOptions, collectionName string) (int64, error)

func (*MongoDbRepository[T]) Create

func (r *MongoDbRepository[T]) Create(entity T, collectionName string) (*T, error)

func (*MongoDbRepository[T]) Get

func (r *MongoDbRepository[T]) Get(filters interface{}, options *options.FindOneOptions, collectionName string) (*T, error)

func (*MongoDbRepository[T]) GetList

func (r *MongoDbRepository[T]) GetList(filters interface{}, options *options.FindOptions, collectionName string) ([]*T, error)

func (*MongoDbRepository[T]) Remove

func (r *MongoDbRepository[T]) Remove(filters interface{}, collectionName string) error

func (*MongoDbRepository[T]) Update

func (r *MongoDbRepository[T]) Update(filters interface{}, entity *T, collectionName string) (*T, error)

Jump to

Keyboard shortcuts

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