repository

package
v0.0.0-...-60f5d5a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package repository provides methods for interacting with the database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRecordID

func NewRecordID() string

NewRecordID -

func NewRecordNullTimestamp

func NewRecordNullTimestamp() sql.NullTime

NewRecordNullTimestamp -

func NewRecordTimestamp

func NewRecordTimestamp() time.Time

NewRecordTimestamp -

func RecordDiff

func RecordDiff(p, pp EquatableRecord, flags ...EqualityFlag) (diff.Changelog, error)

func RecordEqual

func RecordEqual(p, pp EquatableRecord, flags ...EqualityFlag) (bool, error)

Types

type Config

type Config struct {
	TableName          string
	Attributes         []string
	ReadonlyAttributes []string
	ArrayFields        set.Set[string]
}

Config -

type EqualityFlag

type EqualityFlag string
const EqualityFlagExcludeID EqualityFlag = "eo-exclude-id"
const EqualityFlagExcludeTimestamps EqualityFlag = "flag-exclude-timestamps"

type EquatableRecord

type EquatableRecord interface {
	// contains filtered or unexported methods
}

type Record

type Record struct {
	ID        string       `db:"id"`
	CreatedAt time.Time    `db:"created_at"`
	UpdatedAt sql.NullTime `db:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at"`
}

Record -

type Repository

type Repository struct {
	Config  Config
	Log     logger.Logger
	Tx      *sqlx.Tx
	Prepare preparer.Repository
	// contains filtered or unexported fields
}

Repository -

func (*Repository) ArrayFields

func (r *Repository) ArrayFields() set.Set[string]

func (*Repository) Attributes

func (r *Repository) Attributes() []string

func (*Repository) CreateOneRec

func (r *Repository) CreateOneRec(rec interface{}) error

CreateOneRec -

func (*Repository) CreateOneSQL

func (r *Repository) CreateOneSQL() string

CreateOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.

func (*Repository) DeleteManySQL

func (r *Repository) DeleteManySQL() string

DeleteManySQL - This SQL statement ends with a newline so that any parameters can be easily appended.

func (*Repository) DeleteOne

func (r *Repository) DeleteOne(id any) error

DeleteOne -

func (*Repository) DeleteOneSQL

func (r *Repository) DeleteOneSQL() string

DeleteOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.

func (*Repository) GetManyRecs

func (r *Repository) GetManyRecs(opts *coresql.Options) (rows *sqlx.Rows, err error)

GetManyRecs -

func (*Repository) GetManySQL

func (r *Repository) GetManySQL() string

GetManySQL - This SQL statement ends with a newline so that any parameters can be easily appended.

func (*Repository) GetOneRec

func (r *Repository) GetOneRec(recordID any, rec any, lock *coresql.Lock) error

GetOneRec -

func (*Repository) GetOneSQL

func (r *Repository) GetOneSQL() string

GetOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.

func (*Repository) Init

func (r *Repository) Init() error

Init -

func (*Repository) ReadonlyAttributes

func (r *Repository) ReadonlyAttributes() []string

func (*Repository) RemoveManySQL

func (r *Repository) RemoveManySQL() string

RemoveManySQL - This SQL statement ends with a newline so that any parameters can be easily appended.

func (*Repository) RemoveOne

func (r *Repository) RemoveOne(id any) error

RemoveOne -

func (*Repository) RemoveOneSQL

func (r *Repository) RemoveOneSQL() string

RemoveOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.

func (*Repository) TableName

func (r *Repository) TableName() string

TableName -

func (*Repository) UpdateManySQL

func (r *Repository) UpdateManySQL() string

UpdateManySQL -

func (*Repository) UpdateOneRec

func (r *Repository) UpdateOneRec(rec interface{}) error

UpdateOneRec -

func (*Repository) UpdateOneSQL

func (r *Repository) UpdateOneSQL() string

UpdateOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.

Jump to

Keyboard shortcuts

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