storage

package
v0.0.0-...-010a373 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MongoConnect

func MongoConnect() (*mongo.Database, error)

Connects MongoDB and returns mongo.Database struct

func RedisConnect

func RedisConnect() (*redis.Client, error)

Connects Redis and returns redis.Client struct

Types

type AuthRepository

type AuthRepository interface {
	// CreateAuth insert entity to store
	CreateAuth(token *entity.Token) error
	// FindAuth returns entity with matching uuid
	FindAuth(uuid string) (string, error)
	// Delete removes entity from store
	DeleteAuth(uuid string) error
}

AuthRepository interface

type DB

type DB struct {
	// contains filtered or unexported fields
}

func New

func New(mongo *mongo.Database, redis *redis.Client) *DB

Creates new database layer

func (*DB) Auths

func (db *DB) Auths() AuthRepository

Returns auth redis repository

func (*DB) Repos

func (db *DB) Repos() RepoRepository

Returns git repository mongo repository

func (*DB) Subscribers

func (db *DB) Subscribers() SubscriberRepository

Returns subscriber mongo repository

func (*DB) Users

func (db *DB) Users() UserRepository

Returns user mongo repository

type RepoRepository

type RepoRepository interface {
	// Create insert entity to collection
	Create(user *entity.Repo) (*entity.Repo, error)
	// FindByID returns entity with matching id
	FindByID(repoID string) (*entity.Repo, error)
	// FindByEmail returns entity with matching url and user id
	FindByUrlAndUserID(url string, userID string) (*entity.Repo, error)
	// FindAll returns entities belongs to user
	FindAll(userID string) ([]*entity.Repo, error)
	// UpdatePackages insert updated packages into entity
	UpdatePackages(repo *entity.Repo) (*entity.Repo, error)
	// Delete removes entity from collection
	Delete(repoID string) error
	// Delete removes all entities belongs to user
	DeleteMany(userID string) error
}

RepoRepository interface

type Store

type Store interface {
	Repos() RepoRepository
	Subscribers() SubscriberRepository
	Users() UserRepository
	Auths() AuthRepository
}

type SubscriberRepository

type SubscriberRepository interface {
	// Create insert entity to collection
	Create(user *entity.Subscriber) (*entity.Subscriber, error)
	// FindByEmail returns entity with matching email and repository id
	FindByEmailAndRepoID(email string, repoID string) (*entity.Subscriber, error)
	// FindByID returns entity with matching id
	FindByID(subID string) (*entity.Subscriber, error)
	// FindAll returns entities belongs to git repository
	FindAll(repoID string) ([]*entity.Subscriber, error)
	// Update insert updated entity values in collection
	Update(subscriber *entity.Subscriber) (*entity.Subscriber, error)
	// Confirm updates entity when subscriber verify email
	Confirm(subID string, confirmed bool) error
	// GetAll returns all entities in collection
	GetAll() ([]*entity.Subscriber, error)
	// Delete removes entity from collection
	Delete(subID string) error
	// Delete removes all entities belongs to git repository
	DeleteMany(repoID string) error
}

SubscriberRepository interface

type UserRepository

type UserRepository interface {
	// Create insert entity to collection
	Create(user *entity.User) (*entity.User, error)
	// FindByID returns entity with matching id
	FindByID(userID string) (*entity.User, error)
	// FindByEmail returns entity with matching email
	FindByEmail(email string) (*entity.User, error)
	// Update insert updated entity values in collection
	Update(user *entity.User) (*entity.User, error)
	// Confirm updates entity when user verify email
	Confirm(userID string, confirmed bool) error
	// Delete removes entity from collection
	Delete(userID string) error
}

UserRepository interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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