stringdb

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBDir    = "dbs"
	AuthDir  = DBDir + "/system/auth"
	AuthFile = AuthDir + "/" + "user.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	User           *User             `json:"-"`
	DBName         string            `json:"-"`
	CollectionName string            `json:"-"`
	Records        map[string]string `json:"-"`
	DirPath        string            `json:"-"`
	FilePath       string            `json:"-"`
}

func NewCollection

func NewCollection(user *User, dbName string, collectionName string) (*Collection, error)

func (*Collection) DelCollection

func (c *Collection) DelCollection() error

func (*Collection) DelDB

func (c *Collection) DelDB() error

func (*Collection) DelRecord

func (c *Collection) DelRecord(key string) error

func (*Collection) GetAllRecords

func (c *Collection) GetAllRecords() map[string]string

func (*Collection) GetAllRecordsKeys

func (c *Collection) GetAllRecordsKeys() []string

func (*Collection) GetRecord

func (c *Collection) GetRecord(key string) (string, error)

func (*Collection) ModifyRecord

func (c *Collection) ModifyRecord(key string, value string) error

func (*Collection) NewRecord

func (c *Collection) NewRecord(key string, value string) error

func (*Collection) ReadAndSetRecords

func (c *Collection) ReadAndSetRecords() error

func (*Collection) SaveRecordsToFile

func (c *Collection) SaveRecordsToFile() error

type User

type User struct {
	Name              string `json:"name"`
	PlainTextPassword string `json:"-"`
	EncryptedPassword string `json:"password"`
}

func NewUser

func NewUser(name string, password string) (*User, error)

NewUser creates a new user and writes it to the auth file

func (*User) ChangePassword

func (u *User) ChangePassword(newPassword string) (*User, error)

func (*User) DelUser

func (u *User) DelUser() error

func (*User) IsAuthorized

func (u *User) IsAuthorized() error

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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