models

package
v0.0.0-...-0559a69 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB            *mongo.Database
	DB_HOST       string = os.Getenv("MONGO_HOST")
	DB_NAME       string = os.Getenv("MONGO_DBNAME")
	DB_PASS       string = os.Getenv("MONGO_PASSWORD")
	DB_USER       string = os.Getenv("MONGO_USER")
	DB_COLLECTION string = os.Getenv("MONGO_COLLECTION")
)

Functions

func ConfigureDB

func ConfigureDB(ctx context.Context) (*mongo.Client, error)

ConfigureDB initializes a mongo connection client and returns it

func GetDefaultCollection

func GetDefaultCollection(db *mongo.Database) (col *mongo.Collection)

GetDefaultCollection returns the "secret" collection

func TestDbConnection

func TestDbConnection(client *mongo.Client)

TestDbConnection tests mongo connection by sending pings to the mongo database

Types

type Secret

type Secret struct {
	Hash           string `json:"hash" bson:"hash" xml:"hash"`
	SecretText     string `json:"secretText" bson:"secretText" yaml:"secretHash"`
	CreatedAt      int64  `json:"createdAt" bson:"createdAt" yaml:"createdAt"`
	ExpiresAt      int64  `json:"expiresAt" bson:"expiresAt" yaml:"expiresAt"`
	RemainingViews int    `json:"remainingViews,string" bson:"remainingViews" yaml:"remainingViews"`
}

Struct for containing secret

func (*Secret) CreateSecret

func (s *Secret) CreateSecret() error

CreateSecret method creates a new secret

func (*Secret) DeleteSecret

func (s *Secret) DeleteSecret() error

DeleteSecrets method deletes a given secret

func (*Secret) GetSecret

func (s *Secret) GetSecret() error

GetSecret method fetches a secret

func (*Secret) UpdateSecret

func (s *Secret) UpdateSecret() error

UpdateSecret method updates a given secret

Jump to

Keyboard shortcuts

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