database

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2018 License: GPL-3.0 Imports: 17 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Session *mgo.Session
	// contains filtered or unexported fields
}

DB is the workhorse container for messing with the database

func (*DB) AggregateCollection added in v1.0.0

func (d *DB) AggregateCollection(sourceCollection string,
	session *mgo.Session, pipeline []bson.D) *mgo.Iter

AggregateCollection builds a collection via a MongoDB pipeline

func (*DB) CollectionExists added in v1.0.0

func (d *DB) CollectionExists(table string) bool

CollectionExists returns true if collection exists in the currently selected database

func (*DB) CreateCollection added in v1.0.0

func (d *DB) CreateCollection(name string, id bool, indeces []mgo.Index) error

CreateCollection creates a new collection in the currently selected database with the required indeces

func (*DB) GetSelectedDB added in v1.0.0

func (d *DB) GetSelectedDB() string

GetSelectedDB retrieves the currently selected database for analysis

func (*DB) MapReduceCollection added in v1.0.0

func (d *DB) MapReduceCollection(sourceCollection string, job mgo.MapReduce) bool

MapReduceCollection builds collections via javascript map reduce jobs

func (*DB) SelectDB added in v1.0.0

func (d *DB) SelectDB(db string)

SelectDB selects a database for analysis

type DBMetaInfo

type DBMetaInfo struct {
	ID             bson.ObjectId `bson:"_id,omitempty"`   // Ident
	Name           string        `bson:"name"`            // Top level name of the database
	Analyzed       bool          `bson:"analyzed"`        // Has this database been analyzed
	ImportVersion  string        `bson:"import_version"`  // Rita version at import
	AnalyzeVersion string        `bson:"analyze_version"` // Rita version at analyze
}

DBMetaInfo defines some information about the database

type MetaDBHandle

type MetaDBHandle struct {
	DB string // Database path
	// contains filtered or unexported fields
}

MetaDBHandle exports control for the meta database

func (*MetaDBHandle) AddNewDB

func (m *MetaDBHandle) AddNewDB(name string) error

AddNewDB adds a new database to the DBMetaInfo table

func (*MetaDBHandle) AddParsedFiles added in v1.0.0

func (m *MetaDBHandle) AddParsedFiles(files []*fpt.IndexedFile) error

AddParsedFiles adds indexed files to the files the metaDB using the bulk API

func (*MetaDBHandle) CheckCompatibleAnalyze added in v1.0.0

func (m *MetaDBHandle) CheckCompatibleAnalyze(targetDatabase string) (bool, error)

CheckCompatibleAnalyze checks if a database was analyzed with a version of RITA which is compatible with the running version

func (*MetaDBHandle) CheckCompatibleImport added in v1.0.0

func (m *MetaDBHandle) CheckCompatibleImport(targetDatabase string) (bool, error)

CheckCompatibleImport checks if a database was imported with a version of RITA which is compatible with the running version

func (*MetaDBHandle) DeleteDB added in v1.0.0

func (m *MetaDBHandle) DeleteDB(name string) error

DeleteDB removes a database managed by RITA

func (*MetaDBHandle) GetAnalyzedDatabases added in v1.0.0

func (m *MetaDBHandle) GetAnalyzedDatabases() []string

GetAnalyzedDatabases builds a list of database names which have been analyzed

func (*MetaDBHandle) GetDBMetaInfo added in v1.0.0

func (m *MetaDBHandle) GetDBMetaInfo(name string) (DBMetaInfo, error)

GetDBMetaInfo returns a meta db entry

func (*MetaDBHandle) GetDatabases

func (m *MetaDBHandle) GetDatabases() []string

GetDatabases returns a list of databases being tracked in metadb or an empty array on failure

func (*MetaDBHandle) GetFiles

func (m *MetaDBHandle) GetFiles() ([]fpt.IndexedFile, error)

GetFiles gets a list of all IndexedFile objects in the database if successful return a list of files from the database, in the case of failure return a zero length list of files and generat a log message.

func (*MetaDBHandle) GetUnAnalyzedDatabases added in v1.0.0

func (m *MetaDBHandle) GetUnAnalyzedDatabases() []string

GetUnAnalyzedDatabases builds a list of database names which have yet to be analyzed

func (*MetaDBHandle) MarkDBAnalyzed added in v1.0.0

func (m *MetaDBHandle) MarkDBAnalyzed(name string, complete bool) error

MarkDBAnalyzed marks a database as having been analyzed

type Resources added in v1.0.0

type Resources struct {
	Config *config.Config
	Log    *log.Logger
	DB     *DB
	MetaDB *MetaDBHandle
}

Resources provides a data structure for passing system Resources

func InitMockResources added in v1.0.0

func InitMockResources(userConfig string) *Resources

InitMockResources grabs the configuration file and intitializes the configuration data returning a *Resources object which has all of the necessary configuration information

func InitResources added in v1.0.0

func InitResources(userConfig string) *Resources

InitResources grabs the configuration file and intitializes the configuration data returning a *Resources object which has all of the necessary configuration information

Jump to

Keyboard shortcuts

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