Documentation ¶
Index ¶
- func AndMergeFilters(filters ...bson.D) bson.D
- func SearchCommandFilter(command string) bson.D
- func SelectAllFilter() bson.D
- func SelectForUserFilter(user string) bson.D
- func SelectMachineFilter(machine string) bson.D
- func SelectSinceTimestampFilter(ts uint64) bson.D
- func SelectTillTimestampFilter(ts uint64) bson.D
- func SelectTimerangeFilter(start, end uint64) bson.D
- type EntryDocument
- type MongoStore
- func (s *MongoStore) EnsureHistoryIndices(ctx context.Context, recreate bool) error
- func (s *MongoStore) EnsureUserIndices(ctx context.Context, recreate bool) error
- func (s *MongoStore) GetEntries(ctx context.Context, user string, filter bson.D, limit int64) ([]history.Entry, error)
- func (s *MongoStore) GetUser(ctx context.Context, user string) (*User, error)
- func (s *MongoStore) PutUser(ctx context.Context, u *User) error
- func (s *MongoStore) StoreEntries(ctx context.Context, user string, entries []history.Entry) (changed int64, err error)
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AndMergeFilters ¶
AndMergeFilters combines multiple filters with an and operation
func SearchCommandFilter ¶ added in v0.3.0
SearchCommandFilter returns all documents with a regex match of the given string
func SelectForUserFilter ¶
SelectForUserFilter returns all documents for a single user
func SelectMachineFilter ¶ added in v0.3.0
SelectMachineFilter returns all documents with a machine match
func SelectSinceTimestampFilter ¶
SelectSinceTimestampFilter returns all documents since a particular timestamp
func SelectTillTimestampFilter ¶
SelectTillTimestampFilter returns all documents till a particular timestamp
func SelectTimerangeFilter ¶
SelectTimerangeFilter returns all documents within two timestamps
Types ¶
type EntryDocument ¶
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) 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 (*User) CheckPassword ¶
CheckPassword compares the hash of the supplied password against the expected hash