refactoring, fixes and laniakea v0.8
This commit is contained in:
@@ -2,11 +2,10 @@ package mdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kurumibot/database"
|
||||
"time"
|
||||
"ymgb/database"
|
||||
|
||||
"git.nix13.pw/scuroneko/extypes"
|
||||
"git.nix13.pw/scuroneko/laniakea"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/options"
|
||||
)
|
||||
@@ -20,14 +19,14 @@ type ConsoleLogEntry struct {
|
||||
TimeStamp int64 `bson:"timeStamp" json:"time_stamp"`
|
||||
}
|
||||
|
||||
func WriteConsoleLog(db *laniakea.DatabaseContext, e ConsoleLogEntry) error {
|
||||
func WriteConsoleLog(db *database.Context, e ConsoleLogEntry) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
col := database.GetMongoCollection(db, "logs")
|
||||
_, err := col.InsertOne(ctx, e)
|
||||
return err
|
||||
}
|
||||
func GetConsoleLogs(db *laniakea.DatabaseContext) ([]ConsoleLogEntry, error) {
|
||||
func GetConsoleLogs(db *database.Context) ([]ConsoleLogEntry, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
col := database.GetMongoCollection(db, "logs")
|
||||
@@ -52,14 +51,14 @@ type MessageLogEntry struct {
|
||||
TimeStamp int64 `bson:"timestamp" json:"timestamp"`
|
||||
}
|
||||
|
||||
func WriteMessageLog(db *laniakea.DatabaseContext, e *MessageLogEntry) error {
|
||||
func WriteMessageLog(db *database.Context, e *MessageLogEntry) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
col := database.GetMongoCollection(db, "msg_logs")
|
||||
_, err := col.InsertOne(ctx, e)
|
||||
return err
|
||||
}
|
||||
func GetMessageLogs(db *laniakea.DatabaseContext) (extypes.Slice[*MessageLogEntry], error) {
|
||||
func GetMessageLogs(db *database.Context) (extypes.Slice[*MessageLogEntry], error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
col := database.GetMongoCollection(db, "msg_logs")
|
||||
|
||||
Reference in New Issue
Block a user