nanoDB: github.com/jackyzha0/nanoDB/index Index | Files

package index

import "github.com/jackyzha0/nanoDB/index"

Package index contains files responsible for maintaining the database document index

Index

Package Files

index.go io.go resolver.go test_helpers.go

func ResolveReferences Uses

func ResolveReferences(jsonVal interface{}, depthLeft int) interface{}

ResolveReferences tries to find key references and if found, replace the references with their corresponding value

type File Uses

type File struct {
    FileName string
    // contains filtered or unexported fields
}

File stores the filename as well as a read-write mutex

func (*File) Delete Uses

func (f *File) Delete() error

Delete tries to remove the file

func (*File) GetByteArray Uses

func (f *File) GetByteArray() ([]byte, error)

GetByteArray returns the byte array of given file

func (*File) ReplaceContent Uses

func (f *File) ReplaceContent(str string) error

ReplaceContent changes the contents of file f to be str

func (*File) ResolvePath Uses

func (f *File) ResolvePath() string

ResolvePath returns a string representing the path to file

func (*File) ToMap Uses

func (f *File) ToMap() (res map[string]interface{}, err error)

type FileIndex Uses

type FileIndex struct {
    FileSystem af.Fs
    // contains filtered or unexported fields
}

FileIndex is holds the actual index mapping for keys to files

var I *FileIndex

I is the global database index which keeps track of which files are where

func NewFileIndex Uses

func NewFileIndex(dir string) *FileIndex

NewFileIndex returns a reference to a new file index

func (*FileIndex) Delete Uses

func (i *FileIndex) Delete(file *File) error

Delete deletes the given file and then removes it from I

func (*FileIndex) List Uses

func (i *FileIndex) List() (res []string)

List returns all keys in database

func (*FileIndex) Lookup Uses

func (i *FileIndex) Lookup(key string) (*File, bool)

Lookup returns the file with that key Returns (File, true) if file exists otherwise, returns new File, false

func (*FileIndex) Put Uses

func (i *FileIndex) Put(file *File, bytes []byte) error

Put creates/updates file in the fileindex

func (*FileIndex) Regenerate Uses

func (i *FileIndex) Regenerate()

Regenerate rebuilds the current file index from current directory by crawling it for any .json files

func (*FileIndex) RegenerateNew Uses

func (i *FileIndex) RegenerateNew(dir string)

RegenerateNew rebuilds the file index at a new given directory

func (*FileIndex) SetFileSystem Uses

func (i *FileIndex) SetFileSystem(fs af.Fs)

SetFileSystem sets the file system for the given FileIndex

Package index imports 13 packages (graph) and is imported by 2 packages. Updated 2020-09-03. Refresh now. Tools for package owners.