database

package
v0.0.0-...-28ce20d Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package database implements the database for the scanning cabinet.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("file not found")

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

A DB holds metadata for the scanning cabinet. The actual scans are stored separately, as ordinary files.

func Create

func Create(name string) (*DB, error)

Create creates a new database in the named file. The file must not exist.

func Open

func Open(name string) (*DB, error)

Open opens the database in the named file.

func (*DB) Delete

func (db *DB) Delete(doc *Doc) error

Delete deletes the document (or any document with the same doc.ID) from the database.

func (*DB) Enum

func (db *DB) Enum(sortBy string, offset, count int) ([]*Doc, error)

Enum enumerates all the documents in the database, sorting them by 'sortBy', and then returning at most count documents after skipping offset.

func (*DB) Pending

func (db *DB) Pending(sortBy string, offset, count int) ([]*Doc, error)

Pending enumerates the unfiled documents in the database, sorting them by 'sortBy', and then returning at most count documents after skipping offset.

func (*DB) Search

func (db *DB) Search(query, sortBy string, offset, count int) ([]*Doc, error)

Search returns documents matching query, an SQLITE full-text search. The results are ordered by 'sortBy', and at most count results are returned after skipping the first offset results.

func (*DB) SearchFile

func (db *DB) SearchFile(name string) (*Doc, error)

SearchFile searches the database for the document describing the named file.

func (*DB) SearchID

func (db *DB) SearchID(id int64) (*Doc, error)

SearchID searches the database for the document with the given ID.

func (*DB) Thumb

func (db *DB) Thumb(doc *Doc, page, dpi int) ([]byte, error)

Thumb returns a PNG thumbnail for the given page of the given document. The thumbnail shows at most the top three inches of the document, at the given dots-per-inch. It requires Ghostscript to be installed in the executable search path as 'gs'.

func (*DB) Write

func (db *DB) Write(doc *Doc) error

Write adds doc to the database, overwriting any existing entry with the same doc.ID.

type Doc

type Doc struct {
	ID      int64 `dbstore:",rowid,autoinc"`
	File    string
	SHA1    string
	Pages   int
	Size    int64
	Created time.Time

	// user-editable
	Time     time.Time
	Due      time.Time
	Tags     string
	Desc     string
	Text     string
	Location string
}

A Doc is a single document in the database.

Jump to

Keyboard shortcuts

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