dao

package
v0.0.0-...-66c7a0d Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyValueToRawMap

func KeyValueToRawMap(arr []*query.Kv) (json.RawMessage, error)

KeyValueToRawMap helps convert an array of KeyValues in a Map and convert it to json

func RawMapToKeyValue

func RawMapToKeyValue(rawJSON json.RawMessage) ([]*query.Kv, error)

RawMapToKeyValue helps convert an array of KeyValues in a Map and convert it to json

func Transact

func Transact(db *DB, txFunc func(*DBTrans) error) error

Transact wraps your calls in a transaction. If the call should fail with an error it will perform a rollback. Otherwise the transaction will be committed.

Types

type DB

type DB struct {
	*gorp.DbMap
	SecretsKey string
}

func New

func New(conf *config.Postgres, secretsKey string) (*DB, error)

func (*DB) AddSecret

func (secretsDb *DB) AddSecret(inSecret *secrets.Secret) (string, error)

AddSecret adds a secret to the db

func (*DB) DeleteSecret

func (secretsDb *DB) DeleteSecret(id string) (int64, error)

DeleteSecret deletes a secret from the db

func (*DB) GetSecret

func (secretsDb *DB) GetSecret(id string) (*secrets.Secret, error)

GetSecret is used to read a secret from the db

func (*DB) GetSecrets

func (secretsDb *DB) GetSecrets(sortField string, insortOrder secrets.Query_OrderType, pageNr int32,
	perPage int32, filters []*query.Filter) ([]*secrets.Secret, int64, error)

GetSecrets retrieves all secrets from the db matching input query params

func (*DB) Ping

func (secretsDb *DB) Ping() error

Ping the database to in sure it connection is working.

func (*DB) SecretExists

func (secretsDb *DB) SecretExists(id string) (exists bool, err error)

SecretExists is used to tell us if the secret exists in the db

func (*DB) UpdateSecret

func (secretsDb *DB) UpdateSecret(inSecret *secrets.Secret) error

UpdateSecret updates a secret in the db with input values

type DBTrans

type DBTrans struct {
	*gorp.Transaction
}

type SecretTag

type SecretTag struct {
	SecretID string `db:"secret_id"`
	TagID    string `db:"tag_id"`
}

SecretTag used only to (de)serialize database access

Jump to

Keyboard shortcuts

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