database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *lecho.Logger

Logger is global since we will need it everywhere

Functions

func CalculateUUID

func CalculateUUID(time time.Time) (ulid.ULID, error)

CalculateUUID for the incoming file

func DeleteDocument

func DeleteDocument(docULIDSt string, db *storm.DB) error

DeleteDocument fetches the requested document by ULID

func DeleteDocumentFromSearch

func DeleteDocumentFromSearch(deleteDocument Document, searchDB bleve.Index) error

DeleteDocumentFromSearch deletes everything in the search engine

func FetchAllDocuments

func FetchAllDocuments(db *storm.DB) (*[]Document, error)

FetchAllDocuments fetches all the documents in the database

func FetchConfigFromDB

func FetchConfigFromDB(db *storm.DB) (config.ServerConfig, error)

FetchConfigFromDB pulls the server config from the database

func SetupDatabase

func SetupDatabase() (db *storm.DB)

SetupDatabase initializes the storm/bbolt database

func SetupSearchDB

func SetupSearchDB() (bleve.Index, error)

SetupSearchDB sets up new bleve or opens existing

func UpdateDocumentField

func UpdateDocumentField(docULIDSt string, field string, newValue interface{}, db *storm.DB) (int, error)

UpdateDocumentField updates a single field in a document

func WriteConfigToDB

func WriteConfigToDB(serverConfig config.ServerConfig, db *storm.DB)

WriteConfigToDB writes the serverconfig to the database for later retrieval

Types

type Document

type Document struct {
	StormID      int `storm:"id,increment=100"` //all records start at 100 for the ID and go up
	Name         string
	Path         string //full path to the file
	IngressTime  time.Time
	Folder       string
	Hash         string
	ULID         ulid.ULID `storm:"index"` //Have a smaller (than hash) id that can be used in URL's, hopefully speed things up
	DocumentType string    //type of document (pdf, txt, etc)
	FullText     string
	URL          string
}

Document is all of the document information stored in the database

func AddNewDocument

func AddNewDocument(filePath string, fullText string, db *storm.DB, searchDB bleve.Index) (*Document, error)

AddNewDocument adds a new document to the database

func FetchDocument

func FetchDocument(docULIDSt string, db *storm.DB) (Document, int, error)

FetchDocument fetches the requested document by ULID

func FetchDocumentFromPath

func FetchDocumentFromPath(path string, db *storm.DB) (Document, error)

FetchDocumentFromPath fetches the document by document path

func FetchDocuments

func FetchDocuments(docULIDSt []string, db *storm.DB) ([]Document, int, error)

FetchDocuments fetches an array of documents //TODO: Not fucking needed?

func FetchFolder

func FetchFolder(folderName string, db *storm.DB) ([]Document, error)

FetchFolder grabs all of the documents contained in a folder

func FetchNewestDocuments

func FetchNewestDocuments(numberOf int, db *storm.DB) ([]Document, error)

FetchNewestDocuments fetches the documents that were added last

Jump to

Keyboard shortcuts

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