database

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataObject added in v0.8.5

type DataObject struct {
	Length   int64     `json:"length"`
	SHA1     string    `json:"sha1"`
	SHA256   string    `json:"sha256"`
	Modified time.Time `json:"modified"`
}

DataObject is a file object in JSON database

type Database

type Database struct {
	Path      string
	Schema    Schema
	IsChanged bool
}

Database object struct

func NewDatabase

func NewDatabase(path string) (*Database, error)

NewDatabase creates new Database object

func (*Database) Commit

func (d *Database) Commit() error

Commit writes all the in-mem changes to disk

func (*Database) Count

func (d *Database) Count() int

Count returns count of elements in database

func (*Database) DeleteOne added in v0.8.5

func (d *Database) DeleteOne(path string) bool

DeleteOne deletes Data entry for specified path

func (*Database) ListPaths

func (d *Database) ListPaths() []string

ListPaths returns list of files present in database

func (*Database) MapObjects

func (d *Database) MapObjects() map[string]*DataObject

MapObjects Returns objects map

func (*Database) ReadOne

func (d *Database) ReadOne(path string) (*DataObject, bool)

ReadOne reads Data entry for specific file

func (*Database) WriteOne

func (d *Database) WriteOne(path string, data *DataObject) (*DataObject, bool)

WriteOne writes Data entry for specific file

type Schema

type Schema struct {
	Data     map[string]*DataObject `json:"data"`
	Modified time.Time              `json:"modified"`
}

Schema is a container for file objects

Jump to

Keyboard shortcuts

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