store

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AndMergeFilters

func AndMergeFilters(filters ...bson.D) bson.D

AndMergeFilters combines multiple filters with an and operation

func SearchCommandFilter added in v0.3.0

func SearchCommandFilter(command string) bson.D

SearchCommandFilter returns all documents with a regex match of the given string

func SelectAllFilter

func SelectAllFilter() bson.D

SelectAllFilter returns all documents

func SelectForUserFilter

func SelectForUserFilter(user string) bson.D

SelectForUserFilter returns all documents for a single user

func SelectMachineFilter added in v0.3.0

func SelectMachineFilter(machine string) bson.D

SelectMachineFilter returns all documents with a machine match

func SelectSinceTimestampFilter

func SelectSinceTimestampFilter(ts uint64) bson.D

SelectSinceTimestampFilter returns all documents since a particular timestamp

func SelectTillTimestampFilter

func SelectTillTimestampFilter(ts uint64) bson.D

SelectTillTimestampFilter returns all documents till a particular timestamp

func SelectTimerangeFilter

func SelectTimerangeFilter(start, end uint64) bson.D

SelectTimerangeFilter returns all documents within two timestamps

Types

type EntryDocument

type EntryDocument struct {
	history.Entry
	User string
}

EntryDocument is the storage translation for an entry

type MongoStore

type MongoStore struct {
	// contains filtered or unexported fields
}

MongoStore is a struct to represent MongoDB for history entries

func NewMongoStore

func NewMongoStore(uri string) (ms *MongoStore, err error)

NewMongoStore returns a new MongoDB backed store

func (*MongoStore) EnsureHistoryIndices

func (s *MongoStore) EnsureHistoryIndices(ctx context.Context, recreate bool) error

EnsureHistoryIndices makes sure the required indices exist on the database

func (*MongoStore) EnsureUserIndices

func (s *MongoStore) EnsureUserIndices(ctx context.Context, recreate bool) error

EnsureUserIndices makes sure usernames are unique

func (*MongoStore) GetEntries

func (s *MongoStore) GetEntries(ctx context.Context, user string, filter bson.D, limit int64) ([]history.Entry, error)

GetEntries is used to obtain entries based on filters

func (*MongoStore) GetUser

func (s *MongoStore) GetUser(ctx context.Context, user string) (*User, error)

GetUser retrieves a user from the database

func (*MongoStore) PutUser

func (s *MongoStore) PutUser(ctx context.Context, u *User) error

PutUser stores the user in the databse

func (*MongoStore) StoreEntries

func (s *MongoStore) StoreEntries(ctx context.Context, user string, entries []history.Entry) (changed int64, err error)

StoreEntries Stores the entries to the mongo store for the given user

type User

type User struct {
	User     string `bson:"user,omitempty"`
	Password string `bson:"password,omitempty"`
}

User is a struct to hold basic login information

func NewUser

func NewUser(user, password string) (*User, error)

NewUser returns a user with hashed password

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

CheckPassword compares the hash of the supplied password against the expected hash

Jump to

Keyboard shortcuts

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