2040631737
Added LogTable interface
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package darkstorm
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
ErrNotFound = errors.New("no matches found in table")
|
|
)
|
|
|
|
type IDStruct interface {
|
|
GetID() string
|
|
}
|
|
|
|
type Table[T IDStruct] interface {
|
|
Get(ID string) (data T, err error)
|
|
Find(values map[string]any) ([]T, error)
|
|
Insert(data T) error
|
|
Remove(ID string) error
|
|
FullUpdate(ID string, data T) error
|
|
PartUpdate(ID string, update map[string]any) error
|
|
}
|
|
|
|
type LogTable interface {
|
|
Table[Log]
|
|
// Remove all Log items that have a Log.Date value less then the given value.
|
|
RemoveOldLogs(date int)
|
|
}
|
|
|
|
type CrashTable interface {
|
|
Table[CrashReport]
|
|
// Move a crash type to archive. All instances that perfectly match that appear in CrashReport.Individual should be deleted.
|
|
// If a CrashReport ends up with an empty Individual array it should also be deleted.
|
|
Archive(ArchivedCrash)
|
|
IsArchived(IndividualCrash) bool
|
|
// Add the IndividualCrash report to the crash table. If a CrashReport exists that matches, then it gets added to CrashReport.Individual.
|
|
// If an IndividualCrash exists that is a perfect match, Count is incremented instead of adding it to the array.
|
|
InsertCrash(IndividualCrash) error
|
|
}
|