This commit is contained in:
Caleb Gardner
2024-06-23 06:48:40 -05:00
parent 6ed9df45fb
commit 3a35a85100
7 changed files with 35 additions and 6 deletions
+6 -2
View File
@@ -68,8 +68,12 @@ func (m *MongoTable[T]) PartUpdate(ID string, update map[string]any) error {
return res.Err()
}
func (m *MongoTable[CountLog]) RemoveOldLogs(date int) {
m.col.DeleteMany(context.Background(), bson.M{"date": bson.M{"$lt": date}})
func (m *MongoTable[CountLog]) RemoveOldLogs(date int) error {
_, err := m.col.DeleteMany(context.Background(), bson.M{"date": bson.M{"$lt": date}})
if err == mongo.ErrNoDocuments {
return nil
}
return err
}
func (m *MongoTable[CountLog]) Count(platform string) (int, error) {
var filter bson.M