mongo

package
v0.0.0-...-876d392 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acronymbase

type Acronymbase struct {
	Database
}

Acronymbase is an active connection to the database and operations on acronyms

func (*Acronymbase) Get

func (ab *Acronymbase) Get(a string) ([]string, error)

Get returns all associated phrases for an acronym

func (*Acronymbase) Put

func (ab *Acronymbase) Put(a, c string) error

Put adds an association with an acronym and a phrase

type Contentbase

type Contentbase struct {
	Database
}

Contentbase database connection with content lines operations

func (*Contentbase) Insert

func (cb *Contentbase) Insert(lines ...types.ContentLine) error

Insert adds lines to the database

func (*Contentbase) Len

func (cb *Contentbase) Len(id types.StoreID) (count int64, err error)

Len returns number of lines associated with StoreID

func (*Contentbase) RegexSearchFile

func (cb *Contentbase) RegexSearchFile(regex string, id types.StoreID, start int, end int) ([]types.ContentLine, error)

RegexSearchFile returns lines associated with StoreID, within bounds, and matches regular expression

func (*Contentbase) Slice

func (cb *Contentbase) Slice(id types.StoreID, start int, end int) ([]types.ContentLine, error)

Slice returns slices associated with StoreID within bounds

type Database

type Database struct {
	URI       string            `json:"uri"`
	DBName    string            `json:"db"`
	CollNames map[string]string `json:"coll"`
	// contains filtered or unexported fields
}

Database implements database.Database for mongodb

func (*Database) Acronym

func (d *Database) Acronym() database.Acronymbase

Acronym opens a new connection to the database if provided a context and returns Acronymbase type if provided context is nil it will reuse the existing connection

func (*Database) Close

func (d *Database) Close(ctx context.Context) error

Close stops the active connection necessary or else there can be memory leak from unclosed connections

func (*Database) Connect

func (d *Database) Connect(ctx context.Context) (database.Database, error)

Connect establishes a new connection to the mongodb

func (*Database) Content

func (d *Database) Content() database.Contentbase

Content opens a new connection to the database if provided a context and returns Contentbase type if provided context is nil it will reuse the existing connection

func (*Database) File

func (d *Database) File() database.Filebase

File opens a new connection to the database if provided a context and returns Filebase type if provided context is nil it will reuse the existing connection

func (*Database) GetContext

func (d *Database) GetContext() context.Context

GetContext returns context of the current open connection

func (*Database) Init

func (d *Database) Init(ctx context.Context, reset bool) error

Init tests the connection to the database if reset is true, empties out the databases and sets up indexex

func (*Database) Owner

func (d *Database) Owner() database.Ownerbase

Owner opens a new connection to the database if provided a context and returns Ownerbase type if provided context is nil the resulting Ownerbase will reuse the existing connection

func (*Database) Store

func (d *Database) Store() database.Storebase

Store opens a new connection to the database if provided a context and returns Storebase type if provided context is nil it will reuse the existing connection

func (*Database) Tag

func (d *Database) Tag() database.Tagbase

Tag opens a new connection to the database if provided a context and returns Tagbase type if provided context is nil it will reuse the existing connection

func (*Database) View

func (d *Database) View() database.Viewbase

View opens a new connection to the database if provided a context and returns Viewbase type if provided context is nil it will reuse the existing connection

type Filebase

type Filebase struct {
	Database
}

Filebase is a database connection with file operations

func (*Filebase) Count

func (fb *Filebase) Count(uid types.OwnerID, pkeys ...string) (int64, error)

Count returns the total number of files accessible by the ownerid, the optional pkeys are permission values to check in addition to ownership

func (*Filebase) Get

func (fb *Filebase) Get(fid types.FileID) (types.FileI, error)

Get file from id

func (*Filebase) GetAll

func (fb *Filebase) GetAll(fids ...types.FileID) ([]types.FileI, error)

GetAll files from ids

func (*Filebase) GetOwned

func (fb *Filebase) GetOwned(uid types.OwnerID) ([]types.FileI, error)

GetOwned returns all files owned by owner id

func (*Filebase) GetPermKey

func (fb *Filebase) GetPermKey(uid types.OwnerID, pkey string) ([]types.FileI, error)

GetPermKey returns all files that have owner id with provided permission

func (*Filebase) Insert

func (fb *Filebase) Insert(r types.FileI) error

Insert file into database. file id must all ready been reserved, see Reserve

func (*Filebase) MatchStore

func (fb *Filebase) MatchStore(oid types.OwnerID, sid []types.StoreID, pkeys ...string) ([]types.FileI, error)

MatchStore returns all files where an owner either owns the file or has a particular permission, and the file matches one of the provided StoreIDs

func (*Filebase) Remove

func (fb *Filebase) Remove(r types.FileID) error

Remove file with id

func (*Filebase) Reserve

func (fb *Filebase) Reserve(id types.FileID) (types.FileID, error)

Reserve a fileid, will mutate if fileid not available, returns reserved file id

func (*Filebase) Update

func (fb *Filebase) Update(r types.FileI) error

Update File

type Ownerbase

type Ownerbase struct {
	Database
}

Ownerbase is a connection to the databae with owner operations

func (*Ownerbase) CheckResetKey

func (ob *Ownerbase) CheckResetKey(keystr string) (id types.OwnerID, err error)

CheckResetKey looks up a reset key and which owner is associated with that key

func (*Ownerbase) DeleteResetKey

func (ob *Ownerbase) DeleteResetKey(id types.OwnerID) error

DeleteResetKey deletes resetkey pairing to owner id

func (*Ownerbase) FindGroupName

func (ob *Ownerbase) FindGroupName(name string) (types.GroupI, error)

FindGroupName finds group based on name

func (*Ownerbase) FindUserName

func (ob *Ownerbase) FindUserName(name string) (types.UserI, error)

FindUserName returns user based on username

func (*Ownerbase) Get

func (ob *Ownerbase) Get(id types.OwnerID) (types.Owner, error)

Get returns owner based on id

func (*Ownerbase) GetGroups

func (ob *Ownerbase) GetGroups(id types.OwnerID) (owned []types.GroupI, member []types.GroupI, err error)

GetGroups returns owned groups and groups an owner is a member of. based on the id of the owner

func (*Ownerbase) GetResetKey

func (ob *Ownerbase) GetResetKey(id types.OwnerID) (key string, err error)

GetResetKey generates a password reset key

func (*Ownerbase) GetSpace

func (ob *Ownerbase) GetSpace(id types.OwnerID) (int64, error)

GetSpace returns amount of used space an owner has

func (*Ownerbase) GetTotalSpace

func (ob *Ownerbase) GetTotalSpace(id types.OwnerID) (int64, error)

GetTotalSpace returns the amount of total space available to an owner

func (*Ownerbase) Insert

func (ob *Ownerbase) Insert(u types.Owner) (err error)

Insert adds owner to the database, owner id must first be reserved, see Reserve

func (*Ownerbase) Reserve

func (ob *Ownerbase) Reserve(id types.OwnerID, name string) (oid types.OwnerID, err error)

Reserve an owner id, will mutate if owner id not available, returns reserved owner id

func (*Ownerbase) Update

func (ob *Ownerbase) Update(u types.Owner) (err error)

Update owner

type Storebase

type Storebase struct {
	Database
}

Storebase is a connection to the database with file store operations

func (*Storebase) Get

func (db *Storebase) Get(id types.StoreID) (out *types.FileStore, err error)

Get file store

func (*Storebase) Insert

func (db *Storebase) Insert(fs *types.FileStore) error

Insert file store, must reserve store id first, see Reserve

func (*Storebase) MatchHash

func (db *Storebase) MatchHash(h uint32) (out []*types.FileStore, err error)

MatchHash returns all file stores with matching hashes

func (*Storebase) Reserve

func (db *Storebase) Reserve(id types.StoreID) (types.StoreID, error)

Reserve a store id, will mutate if store id not available, returns reserved store id

func (*Storebase) UpdateMeta

func (db *Storebase) UpdateMeta(fs *types.FileStore) error

UpdateMeta of file store

type Tagbase

type Tagbase struct {
	Database
}

Tagbase is a connection to the database with tag operations

func (*Tagbase) Get

func (tb *Tagbase) Get(fid types.FileID, oid types.OwnerID) ([]tag.FileTag, error)

Get returns all filetags for a particular file id and owner

func (*Tagbase) GetAll

func (tb *Tagbase) GetAll(typ tag.Type, oid types.OwnerID) ([]tag.FileTag, error)

GetAll returns all FileTags that have a particular type and and owner. Since it looks for owner association, store tags are not searched

func (*Tagbase) GetType

func (tb *Tagbase) GetType(fid types.FileID, oid types.OwnerID, typ tag.Type) ([]tag.FileTag, error)

GetType returns FileTags of a particular file, for a particular owner, with a match to a particular type

func (*Tagbase) Remove

func (tb *Tagbase) Remove(tags ...tag.FileTag) error

Remove tags from database

func (*Tagbase) SearchAccess

func (tb *Tagbase) SearchAccess(oid types.OwnerID, pkey string, tags ...tag.FileTag) ([]types.FileID, error)

SearchAccess returns all fileids that the owner has access to in a particular permission and match the filtering tags

func (*Tagbase) SearchFiles

func (tb *Tagbase) SearchFiles(fids []types.FileID, tags ...tag.FileTag) ([]types.FileID, error)

SearchFiles returns all the fileids that match the tags which define the filter conditions

func (*Tagbase) SearchOwned

func (tb *Tagbase) SearchOwned(oid types.OwnerID, tags ...tag.FileTag) ([]types.FileID, error)

SearchOwned returns all fileids that are owned by the owner and match the filtering tags

func (*Tagbase) Upsert

func (tb *Tagbase) Upsert(tags ...tag.FileTag) error

Upsert adds tag to the database

type Viewbase

type Viewbase struct {
	Database
}

Viewbase is a connection to the database with pdf view operations

func (*Viewbase) Get

func (vb *Viewbase) Get(id types.StoreID) (out *types.ViewStore, err error)

Get view from database

func (*Viewbase) Insert

func (vb *Viewbase) Insert(vs *types.ViewStore) error

Insert adds pdf view to the database

Jump to

Keyboard shortcuts

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