postgres

package
v0.0.0-...-16accc7 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPgPool

func NewPgPool(ctx context.Context, cfg *config.DBConfig) (*pgxpool.Pool, error)

Types

type File

type File interface {
	Create(ctx context.Context, file *model.File) error
	FindByID(ctx context.Context, id string) (*model.File, error)
	FindUserFiles(ctx context.Context, userID string) ([]*model.File, error)
	AddPermission(ctx context.Context, fileID, username string) error
	HasPermission(ctx context.Context, fileID, username string) (bool, error)
	DeletePermission(ctx context.Context, fileID, username string) error
	Delete(ctx context.Context, id string) error
	FindPermissionsToFile(ctx context.Context, id, creatorID string) ([]*string, error)
	TogglePublic(ctx context.Context, id, creatorID string) error
}

type Folder

type Folder interface {
	Create(ctx context.Context, f model.Folder) error
	FindByID(ctx context.Context, id string) (*model.Folder, error)
	HasPermission(ctx context.Context, id, username string) (bool, error)
	Update(ctx context.Context, id string, fields map[string]interface{}) error
	GetFolderContents(ctx context.Context, id string) ([]*model.File, []*model.Folder, error)
	GetUserFolders(ctx context.Context, userID string) ([]*model.Folder, error)
	AddPermission(ctx context.Context, folderID, username string) error
	DeletePermission(ctx context.Context, folderID, username string) error
	GetPermissions(ctx context.Context, folderID, creatorID string) ([]*string, error)
	HasFile(ctx context.Context, folderID, filename string) (bool, error)
	HasFolder(ctx context.Context, userID, folderName string) (bool, error)
	HasFolderInFolder(ctx context.Context, folderName, folderID string) (bool, error)
}

type PostgresRepository

type PostgresRepository struct {
	UserSpace
	Folder
	File
}

func NewPostgresRepo

func NewPostgresRepo(db *pgxpool.Pool) *PostgresRepository

type UserSpace

type UserSpace interface {
	Create(ctx context.Context, d model.UserSpace) error
	GetByUserID(ctx context.Context, userID string) (*model.UserSpace, error)
	GetFull(ctx context.Context, userID string) (*model.FullUserSpace, error)
	GetByUsername(ctx context.Context, username string) (*model.UserSpace, error)
	GetSize(ctx context.Context, userID string) (int64, error)
	UpdateLevel(ctx context.Context, userID string, newLevel uint8) error
}

Jump to

Keyboard shortcuts

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