drivers

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: 5 Imported by: 2

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBDriver

type DBDriver interface {
	Search(string, bool, bool) (SearchFeed, error)
	Insert(string, *DBObj, bool) error
	Delete(string) error
}

DBDriver defines our database interface, so that different drivers can be swapped out, as needed.

type DBObj

type DBObj struct {
	Key string
	Obj interface{}
}

DBObj holds our database objects, along with the key, for convenience

type SQ3Driver

type SQ3Driver struct {
	Location string
	DB       *sql.DB
}

SQ3Driver is our DBDriver for sqlite3

func NewSqlite

func NewSqlite(dataDir string) (*SQ3Driver, error)

NewSqlite allocates a new sqlite3 driver connection.

func (*SQ3Driver) Delete

func (sq *SQ3Driver) Delete(key string) error

Delete also returns the object it deleted. The key must be an exact match

func (*SQ3Driver) Insert

func (sq *SQ3Driver) Insert(key string, obj *DBObj, force bool) error

Insert adds a new record to the DB, it will return an error if the object already exists, unless force is specified.

func (*SQ3Driver) Search

func (sq *SQ3Driver) Search(pattern string, ignoreCase, searchContent bool) (SearchFeed, error)

Search is our search function for sqlite3

type SearchFeed

type SearchFeed chan *DBObj

SearchFeed is our channel to receive search results on

Jump to

Keyboard shortcuts

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