db

package
v0.0.0-...-e57d8e2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package db handles database interaction for thymeline

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOpDirs

func GetOpDirs(s Session) ([]string, error)

GetOpDirs queries the OpDir collection for a list of all operation directories

Returns A slice of strings containing paths to operation screenshot directories

func GetOpNameFromPath

func GetOpNameFromPath(s Session, path string) (string, error)

GetOpNameFromPath gets the Name property of an OpDir and returns if it exists

func RemoveOpDir

func RemoveOpDir(s Session, opname string) error

RemoveOpDir removes a document from the Database_DB OpDir collection

func SaveScreenshot

func SaveScreenshot(s *Session, screenshot interface{}) error

SaveScreenshot stores a screenshot to the local Event Cache

Types

type Op

type Op struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

Op is a map of operation names and their local path

type OpDir

type OpDir struct {
	ID bson.ObjectId `json:"id" bson:"_id,omitempty"`
	// Operation map[string]string `json:"operation" bson:"operation"`
	Operation Op
}

OpDir hold a map that links directory paths to operation names

func (OpDir) AddToDB

func (od OpDir) AddToDB(s Session) error

AddToDB adds an Operation to the Directory Database

type ScreenshotEvent

type ScreenshotEvent struct {
	ID          bson.ObjectId `json:"id" bson:"_id,omitempty"`
	Timestamp   time.Time     `json:"timestamp"`
	OpName      string        `json:"op_name"`
	Description string        `json:"description"`
	Filename    string        `json:"filename"`
	LocalPath   string        `json:"local_path"`
	Hash        string        `json:"hash"`
}

Screenshot contains a single screenshot event

type Session

type Session struct {
	*mgo.Session
}

Session wraps an pointer to an mgo.Session and adds convenience methods

func Connect

func Connect() (*Session, error)

Connect connects to a MongoDB server and initiates a session

Returns *Session - pointer to a Session error if any

func (*Session) GetCollection

func (s *Session) GetCollection(db string, collection string) *mgo.Collection

GetCollection gets a collection from a database given a valid session and returns a pointer to the collection

Jump to

Keyboard shortcuts

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