filedb

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FileDatabasePath is the path to look for database
	FileDatabasePath = ".filedb"
	// DB is an instance of a database connection
	DB *gorm.DB
)
View Source
var (
	// ErrDatabaseNotPresent will be returned whenever a crud operation is performed in a non-initialized diretory
	ErrDatabaseNotPresent = fmt.Errorf("Database file does not exist. Please run init")
)

Functions

func CloseDB

func CloseDB() error

CloseDB disconnects from database

func ConnectDB

func ConnectDB() error

ConnectDB opens a database and migrates

func Initialize

func Initialize() error

Initialize called to create an empty database

func SetLogger

func SetLogger(newLogger *zap.Logger)

SetLogger is used to set another logger

Types

type File

type File struct {
	ID           int `gorm:"primary_key"`
	RelativePath string
	Hash         string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

File represents the data stored for one file

func Get

func Get(path string) (*File, error)

Get retrieves file information from the database

func (File) Delete

func (file File) Delete() error

Delete removes a file from the database

func (File) Save

func (file File) Save() error

Save stores file information in

Jump to

Keyboard shortcuts

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