db

package
v0.0.0-...-bb9d0af Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: MIT Imports: 2 Imported by: 3

Documentation

Overview

Package db contains our database interface for dfind.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search(pattern string, ignoreCase, searchContent bool, dataDir string) ([]*drivers.DBObj, error)

Search is our top level search function. it should only be used when you do not need to do anything except a single search. It is also a good example of how to implement channel based searches

Types

type DB

type DB struct {
	ReadOnly bool             // the searcher should only connect read only
	Driver   drivers.DBDriver // our actual driver
}

DB holds our database connection. It is used by both the searcher and scanner to access the database.

func New

func New(readOnly bool, dataDir string) (*DB, error)

New will connect to our database(s) and return a DB instance that can be used to access the database

func (*DB) Delete

func (db *DB) Delete(key string) error

Delete removes an item in our database.

func (*DB) Insert

func (db *DB) Insert(key string, obj *drivers.DBObj, updateIfExists bool) error

Insert adds or updates an item in our database.

func (*DB) Search

func (db *DB) Search(pattern string, ignoreCase, searchContent bool) (drivers.SearchFeed, error)

Search is our normal search mechanism, that can be called from any DB instance. There is also a package-level Search function, but, that allocates a DB instance on the fly, and should only be used when you don't need to do anything with the DB except for search. Returns: a channel that returns matches, and/or error.

Directories

Path Synopsis
Package drivers contains our database driver connections, that can be used interchangeably by using interfaces
Package drivers contains our database driver connections, that can be used interchangeably by using interfaces

Jump to

Keyboard shortcuts

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