postgres

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: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPostgresDatabaseObject

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

type IPostgresRepository

type IPostgresRepository[T IPostgresDatabaseObject] interface {
	Create(entity T, table string) (*T, error)
	Count(whereStatement interface{}, table string) (int64, error)
	Get(whereStatement interface{}, table string) (*T, error)
	GetList(whereStatement interface{}, table string) ([]T, error)
	Update(entity T, whereStatement interface{}, table string) (*T, error)
	Remove(whereStatement interface{}, table string) error
}

type PostgresDatabaseObject

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

func (*PostgresDatabaseObject) GetCreatedAt

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

func (*PostgresDatabaseObject) GetIsActive

func (do *PostgresDatabaseObject) GetIsActive() bool

func (*PostgresDatabaseObject) GetUpdatedAt

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

func (*PostgresDatabaseObject) SetCreatedAt

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

func (*PostgresDatabaseObject) SetIsActive

func (do *PostgresDatabaseObject) SetIsActive(isActive bool)

func (*PostgresDatabaseObject) SetUpdatedAt

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

type PostgresRepository

type PostgresRepository[T IPostgresDatabaseObject] struct {
	// contains filtered or unexported fields
}

func NewPostgresRepository

func NewPostgresRepository[T IPostgresDatabaseObject](db *gorm.DB) *PostgresRepository[T]

func (*PostgresRepository[T]) Count

func (r *PostgresRepository[T]) Count(whereStatement interface{}, table string) (int64, error)

func (*PostgresRepository[T]) Create

func (r *PostgresRepository[T]) Create(entity *T, table string) (*T, error)

func (*PostgresRepository[T]) Get

func (r *PostgresRepository[T]) Get(whereStatement interface{}, table string) (*T, error)

func (*PostgresRepository[T]) GetList

func (r *PostgresRepository[T]) GetList(whereStatement interface{}, table string) ([]T, error)

func (*PostgresRepository[T]) Remove

func (r *PostgresRepository[T]) Remove(whereStatement interface{}, table string) error

func (*PostgresRepository[T]) Update

func (r *PostgresRepository[T]) Update(entity T, whereStatement interface{}, table string) (*T, error)

Jump to

Keyboard shortcuts

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