Move darkstorm_backend to just backend

Added MongoDB instances of DB tables
Updated some DB interfaces
Added logging to count cleanup
This commit is contained in:
Caleb Gardner
2024-06-12 03:31:09 -05:00
parent e3af23873f
commit 28654e237e
15 changed files with 246 additions and 22 deletions
+38
View File
@@ -0,0 +1,38 @@
package backend
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 CountTable interface {
Table[CountLog]
// Remove all Log items that have a CountLog.Date value less then the given value.
RemoveOldLogs(date int) error
// Get count. If platform is an empty string or "all", the full count should be given
Count(platform string) (int, error)
}
type CrashTable interface {
Table[CrashReport]
// Move a crash type to archive. Crashes that match the archived crash will be automatically removed from the CrashTable.
Archive(ArchivedCrash) error
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
}