db

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound error = errors.New("not found")

Functions

This section is empty.

Types

type CrashTable

type CrashTable interface {
	Table
	// Add the individual crash to the given crash group.
	// Should be able to parse the crash's error and first line
	// and add it to the appropriate crash group.
	// Should also detect if the given individual crash has already been added.
	AddCrash(c crash.Individual) error
}

type LogTable added in v0.3.0

type LogTable interface {
	Table
	// Returns a list of keys that have a lastCon value that's less then the given value.
	// lastCon is a date stored in YYYYMMDD format.
	LogsOlderThen(value int) ([]string, error)
}

type MongoTable

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

Satisfies both db.Table and db.CrashTable.

func NewMongoTable

func NewMongoTable(c *mongo.Collection) *MongoTable

func (MongoTable) Add

func (m MongoTable) Add(v any) (string, error)

func (MongoTable) AddCrash

func (m MongoTable) AddCrash(c crash.Individual) error

func (MongoTable) Contains

func (m MongoTable) Contains(values map[string]any) (bool, error)

func (MongoTable) Count added in v0.3.0

func (m MongoTable) Count(filter map[string]any) (int64, error)

func (MongoTable) Delete

func (m MongoTable) Delete(key string) error

func (MongoTable) Find

func (m MongoTable) Find(values map[string]any, v any) (err error)

func (MongoTable) FindMany

func (m MongoTable) FindMany(values map[string]any, v any) (err error)

func (MongoTable) Get

func (m MongoTable) Get(key string, v any) error

func (MongoTable) Has

func (m MongoTable) Has(key string) (bool, error)

func (MongoTable) IncrementAndUpdateLastTimeout

func (m MongoTable) IncrementAndUpdateLastTimeout(id string, t int64) error

func (MongoTable) IncrementFailed

func (m MongoTable) IncrementFailed(id string) error

func (MongoTable) LogsOlderThen added in v0.3.0

func (m MongoTable) LogsOlderThen(value int) ([]string, error)

func (MongoTable) Update

func (m MongoTable) Update(key string, v any) error

type Table

type Table interface {
	// Get's the item with the given key then marshals it into v.
	// If not found, return ErrNotFound
	Get(key string, v any) error
	// Attempt to find an item with the given values.
	// If found, marshall into v.
	// If query is successful, but can't be found, return ErrNotFound.
	Find(values map[string]any, v any) (err error)
	// Similiar to Find, but is expected to return multiple items.
	// v must be a slice.
	FindMany(values map[string]any, v any) (err error)
	// Add a new item to the table.
	// If the value given does not contain a key value (or _id for mongoDB), then you can get the value's key from the return.
	Add(v any) (key string, err error)
	// Update an existing key. This should do a full replacement of values.
	Update(key string, v any) error
	// Check if an item with the given key exists.
	Has(key string) (bool, error)
	// Check if an item with the given values exists.
	Contains(values map[string]any) (bool, error)
	// Delete the given item.
	Delete(key string) error
	// Count of documents with the given filter applied
	Count(filter map[string]any) (int64, error)
}

type UserTable

type UserTable interface {
	Table
	// Increment the "failed" field of the user with the given id by 1.
	IncrementFailed(id string) error
	// Same as IncrementFailed but also update the "lastTimeout" field with the given time.
	IncrementAndUpdateLastTimeout(id string, t int64) error
}

Jump to

Keyboard shortcuts

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