{"modulePath":"github.com/ocmdev/rita","version":"v3.2.1+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package database\n\n## Variables\n\n```go\nvar MaxMongoDBVersion = semver.Version{\n\tMajor: 3,\n\tMinor: 7,\n\tPatch: 0,\n}\n```\nMaxMongoDBVersion is the upper, exclusive bound on the versions of MongoDB compatible with RITA\n\n```go\nvar MinMongoDBVersion = semver.Version{\n\tMajor: 3,\n\tMinor: 2,\n\tPatch: 0,\n}\n```\nMinMongoDBVersion is the lower, inclusive bound on the versions of MongoDB compatible with RITA\n\n## Types\n\n```go\ntype DB struct {\n\tSession *mgo.Session\n\t// contains filtered or unexported fields\n}\n```\nDB is the workhorse container for messing with the database\n\n```go\nfunc NewDB(conf *config.Config, log *log.Logger) (*DB, error)\n```\nNewDB constructs a new DB struct\n\n```go\nfunc (d *DB) AggregateCollection(sourceCollection string,\n\tsession *mgo.Session, pipeline []bson.D) *mgo.Iter\n```\nAggregateCollection builds a collection via a MongoDB pipeline\n\n```go\nfunc (d *DB) CollectionExists(table string) bool\n```\nCollectionExists returns true if collection exists in the currently selected database\n\n```go\nfunc (d *DB) CreateCollection(name string, indexes []mgo.Index) error\n```\nCreateCollection creates a new collection in the currently selected database with the required indexes\n\n```go\nfunc (d *DB) GetSelectedDB() string\n```\nGetSelectedDB retrieves the currently selected database for analysis\n\n```go\nfunc (d *DB) SelectDB(db string)\n```\nSelectDB selects a database for analysis\n\n```go\ntype DBMetaInfo struct {\n\tID             bson.ObjectId `bson:\"_id,omitempty\"`   // Ident\n\tName           string        `bson:\"name\"`            // Top level name of the database\n\tAnalyzed       bool          `bson:\"analyzed\"`        // Has this database been analyzed\n\tAnalyzeVersion string        `bson:\"analyze_version\"` // Rita version at analyze\n\tRolling        bool          `bson:\"rolling\"`\n\tTotalChunks    int           `bson:\"total_chunks\"`\n\tCurrentChunk   int           `bson:\"current_chunk\"`\n\tTsRange        Range         `bson:\"ts_range\"`\n}\n```\nDBMetaInfo defines some information about the database\n\n```go\ntype LogInfo struct {\n\tID      bson.ObjectId `bson:\"_id,omitempty\"`   // Ident\n\tTime    time.Time     `bson:\"LastUpdateCheck\"` // Top level name of the database\n\tMessage string        `bson:\"Message\"`         // Top level name of the database\n\tVersion string        `bson:\"NewestVersion\"`   // Top level name of the database\n}\n```\nLogInfo defines information about the UpdateChecker log\n\n```go\ntype MetaDB struct {\n\t// contains filtered or unexported fields\n}\n```\nMetaDB exports control for the meta database\n\n```go\nfunc NewMetaDB(config *config.Config, dbHandle *mgo.Session,\n\tlog *log.Logger) *MetaDB\n```\nNewMetaDB instantiates a new handle for the RITA MetaDatabase\n\n```go\nfunc (m *MetaDB) AddNewDB(name string, currentChunk, totalChunks int) error\n```\nAddNewDB adds a new database to the DBMetaInfo table. All new databases are ready to be rolling databases.\n\n```go\nfunc (m *MetaDB) AddParsedFiles(files []*fpt.IndexedFile) error\n```\nAddParsedFiles adds indexed files to the files the metaDB using the bulk API\n\n```go\nfunc (m *MetaDB) AddTSRange(name string, min int64, max int64) error\n```\nAddTSRange adds the min and max timestamps found in current dataset\n\n```go\nfunc (m *MetaDB) CheckCompatibleAnalyze(targetDatabase string) (bool, error)\n```\nCheckCompatibleAnalyze checks if a database was analyzed with a version of RITA which is compatible with the running version\n\n```go\nfunc (m *MetaDB) DBExists(name string) (bool, error)\n```\nDBExists returns whether or not a metadatabase record has been created for a database\n\n```go\nfunc (m *MetaDB) DeleteDB(name string) error\n```\nDeleteDB removes a database managed by RITA\n\n```go\nfunc (m *MetaDB) GetAnalyzedDatabases() []string\n```\nGetAnalyzedDatabases builds a list of database names which have been analyzed\n\n```go\nfunc (m *MetaDB) GetDBMetaInfo(name string) (DBMetaInfo, error)\n```\nGetDBMetaInfo returns a meta db entry. This is the only function which returns DBMetaInfo to code outside of meta.go.\n\n```go\nfunc (m *MetaDB) GetDatabases() []string\n```\nGetDatabases returns a list of databases being tracked in metadb or an empty array on failure\n\n```go\nfunc (m *MetaDB) GetFiles(database string) ([]fpt.IndexedFile, error)\n```\nGetFiles gets a list of all IndexedFile objects associated with the given database. If successful return a list of files from the database. On failure return an empty list of files and generate a log message.\n\n```go\nfunc (m *MetaDB) GetRollingSettings(db string) (exists bool, isRolling bool, currChunk int, totalChunks int, err error)\n```\nGetRollingSettings gets the current rolling settings\n\n```go\nfunc (m *MetaDB) GetTSRange(name string) (int64, int64, error)\n```\nGetTSRange adds the min and max timestamps for current dataset\n\n```go\nfunc (m *MetaDB) GetUnAnalyzedDatabases() []string\n```\nGetUnAnalyzedDatabases builds a list of database names which have yet to be analyzed\n\n```go\nfunc (m *MetaDB) IsChunkSet(cid int, db string) (bool, error)\n```\nIsChunkSet ....\n\n```go\nfunc (m *MetaDB) LastCheck() (time.Time, semver.Version)\n```\nLastCheck returns most recent version check\n\n```go\nfunc (m *MetaDB) MarkDBAnalyzed(name string, complete bool) error\n```\nMarkDBAnalyzed marks a database as having been analyzed\n\n```go\nfunc (m *MetaDB) RemoveFilesByChunk(database string, cid int) error\n```\nRemoveFilesByChunk removes FilesTable entries for a given database chunk. This helps provide the ability to re-import a given chunk.\n\n```go\nfunc (m *MetaDB) SetChunk(cid int, db string, analyzed bool) error\n```\nSetChunk ....\n\n```go\nfunc (m *MetaDB) SetRollingSettings(db string, chunk int, numchunks int) error\n```\nSetRollingSettings ensures that a given db is marked as rolling, ensures that total\\_chunks matches numchunks, and sets the current\\_chunk to chunk.\n\n```go\ntype Range struct {\n\tMin int64 `bson:\"min\"`\n\tMax int64 `bson:\"max\"`\n}\n```\nRange defines a min and max value\n\n","path":"github.com/ocmdev/rita/database","name":"database","synopsis":"","isRedistributable":true}
