okrzejahauru.club/x/okrzeja/storage/sqlite Index | Files

package sqlite

import "hauru.club/x/okrzeja/storage/sqlite"

Package sqlite implements storage interface for embedded sqlite3 database.

Index

Constants

const TimeLayout = "2006-01-02 15:04:05.999"

TimeLayout is sqlite time format used for default time values. SQLite always uses UTC time zone.

Functions

func Migrate

func Migrate(db *sql.DB) error

Types

type Activity

type Activity struct {
	ID        string
	OwnerID   string
	Atype     string
	CreatedAt string
	Details   []byte
}

type Admin

type Admin struct {
	ID         string
	PromotedAt string
}

type Config

type Config struct {
	ID        string
	CreatedAt string
	Content   []byte
}

type CreateNewFileParams

type CreateNewFileParams struct {
	ID      string
	Parent  sql.NullString
	Name    string
	Content []byte
	Mime    string
}

type CreateNewUserParams

type CreateNewUserParams struct {
	ID       string
	Username string
	Password []byte
}

type CreateRoleParams

type CreateRoleParams struct {
	ResourceName string
	ResourceID   string
	UserID       string
	Name         string
}

type Csrf

type Csrf struct {
	Token     string
	SessionID string
	CreatedAt string
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Filesystem

type Filesystem struct {
	ID            string
	Parent        sql.NullString
	Name          string
	Content       []byte
	CreatedAt     string
	LastUpdatedAt string
	Mime          string
}

type PushConfigParams

type PushConfigParams struct {
	ID        string
	Content   []byte
	CreatedAt string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CountAdmins

func (q *Queries) CountAdmins(ctx context.Context) (int64, error)

func (*Queries) CountAllFiles

func (q *Queries) CountAllFiles(ctx context.Context) (int64, error)

func (*Queries) CountUsersSessions

func (q *Queries) CountUsersSessions(ctx context.Context, username string) (int64, error)

func (*Queries) CreateNewFile

func (q *Queries) CreateNewFile(ctx context.Context, arg CreateNewFileParams) (Filesystem, error)

func (*Queries) CreateNewUser

func (q *Queries) CreateNewUser(ctx context.Context, arg CreateNewUserParams) (User, error)

func (*Queries) CreateRole

func (q *Queries) CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)

func (*Queries) DeleteDanglingFiles

func (q *Queries) DeleteDanglingFiles(ctx context.Context) error

func (*Queries) DeleteDeadRoles

func (q *Queries) DeleteDeadRoles(ctx context.Context, resourceName string) error

func (*Queries) DeleteFile

func (q *Queries) DeleteFile(ctx context.Context, id string) (Filesystem, error)

func (*Queries) DeleteSession

func (q *Queries) DeleteSession(ctx context.Context, id string) (Session, error)

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id string) error

func (*Queries) MakeAdminNow

func (q *Queries) MakeAdminNow(ctx context.Context, id string) (Admin, error)

func (*Queries) PushConfig

func (q *Queries) PushConfig(ctx context.Context, arg PushConfigParams) (Config, error)

func (*Queries) ReadAdminUsernames

func (q *Queries) ReadAdminUsernames(ctx context.Context) ([]string, error)

func (*Queries) ReadFile

func (q *Queries) ReadFile(ctx context.Context, id string) (Filesystem, error)

func (*Queries) ReadFilesFromDirectory

func (q *Queries) ReadFilesFromDirectory(ctx context.Context, parent sql.NullString) ([]Filesystem, error)

func (*Queries) ReadIsAdmin

func (q *Queries) ReadIsAdmin(ctx context.Context, id string) (bool, error)

func (*Queries) ReadLatestConfig

func (q *Queries) ReadLatestConfig(ctx context.Context) (Config, error)

func (*Queries) ReadRolesOfUserForResource

func (q *Queries) ReadRolesOfUserForResource(ctx context.Context, arg ReadRolesOfUserForResourceParams) ([]string, error)

func (*Queries) ReadSession

func (q *Queries) ReadSession(ctx context.Context, id string) (ReadSessionRow, error)

func (*Queries) ReadUser

func (q *Queries) ReadUser(ctx context.Context, id string) (User, error)

func (*Queries) ReadUserByUsername

func (q *Queries) ReadUserByUsername(ctx context.Context, lower string) (User, error)

func (*Queries) ReadUserFile

ReadUserFile returns file data of file owned by user with given username.

func (*Queries) ReadUserRoles

func (q *Queries) ReadUserRoles(ctx context.Context, arg ReadUserRolesParams) ([]Role, error)

func (*Queries) SearchUsersByUsername

func (q *Queries) SearchUsersByUsername(ctx context.Context, arg SearchUsersByUsernameParams) ([]User, error)

func (*Queries) UpdateFileContent

func (q *Queries) UpdateFileContent(ctx context.Context, arg UpdateFileContentParams) error

func (*Queries) UpdateFileName

func (q *Queries) UpdateFileName(ctx context.Context, arg UpdateFileNameParams) error

func (*Queries) UpdateModTimeNow

func (q *Queries) UpdateModTimeNow(ctx context.Context, id string) error

func (*Queries) UpdateUserPassword

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

func (*Queries) WriteSession

func (q *Queries) WriteSession(ctx context.Context, arg WriteSessionParams) (Session, error)

type ReadRolesOfUserForResourceParams

type ReadRolesOfUserForResourceParams struct {
	UserID       string
	ResourceName string
	ResourceID   string
}

type ReadSessionRow

type ReadSessionRow struct {
	ID            string
	CreatedAt     string
	Ttl           int64
	OwnerID       string
	OwnerUsername string
}

type ReadUserFileRequest

type ReadUserFileRequest struct {
	OwnerUsername string
	Path          string
}

ReadUserFileRequest contains arguments for requesting single file reequest.

type ReadUserFileResponse

type ReadUserFileResponse struct {
	ID            string
	Parent        sql.NullString
	Name          string
	Content       []byte
	CreatedAt     string
	LastUpdatedAt string
	MIME          string
	Path          string
}

ReadUserFileResponse contains fields related to single file stored in the filesystem table.

type ReadUserRolesParams

type ReadUserRolesParams struct {
	UserID       string
	ResourceName string
}

type Role

type Role struct {
	ResourceName string
	ResourceID   string
	UserID       string
	Name         string
}

type SearchUsersByUsernameParams

type SearchUsersByUsernameParams struct {
	CreatedAt string
	Username  string
	Limit     int64
}

type Session

type Session struct {
	ID        string
	CreatedAt string
	Ttl       int64
	OwnerID   string
}

type UpdateFileContentParams

type UpdateFileContentParams struct {
	Content []byte
	ID      string
}

type UpdateFileNameParams

type UpdateFileNameParams struct {
	Name string
	ID   string
}

type UpdateUserPasswordParams

type UpdateUserPasswordParams struct {
	Password []byte
	ID       string
}

type User

type User struct {
	ID            string
	Username      string
	Password      []byte
	CreatedAt     string
	LastUpdatedAt string
}

type UsersOwnershipFix

type UsersOwnershipFix struct {
	UserID string
}

type Var

type Var struct {
	Key   string
	Value sql.NullString
}

type Void

type Void struct {
	ID        int64
	Source    string
	Content   []byte
	DeletedAt string
}

type WriteSessionParams

type WriteSessionParams struct {
	ID        string
	CreatedAt string
	Ttl       int64
	OwnerID   string
}

Source Files

admin.sql.gen.go config.sql.gen.go db.gen.go fileserver.go fileserver.sql.gen.go models.gen.go roles.sql.gen.go sessions.sql.gen.go sqlite.go users.sql.gen.go

Version
v0.0.0-20231010043146-4292577f982b (latest)
Published
Oct 10, 2023
Platform
linux/amd64
Imports
6 packages
Last checked
1 day ago

Tools for package owners.