init project

This commit is contained in:
2025-03-19 13:47:29 +07:00
parent 80d1f95f66
commit f6a2cf3a5b
22 changed files with 677 additions and 24 deletions

View File

@@ -0,0 +1,29 @@
package mongo
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"log"
"template_blueprint/pkg/models/local"
"time"
)
func (s *DatabaseService) GetDataLog() ([]*local.StartUpLog, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
dataLog, err := s.DB.Collection("startup_log").Find(ctx, bson.M{})
if err != nil {
log.Println("MASUK SINI")
log.Println(err)
return nil, err
}
log.Println("Data", dataLog.Current)
var logs []*local.StartUpLog
errDecode := dataLog.All(ctx, &logs)
if errDecode != nil {
log.Println(errDecode)
return nil, errDecode
}
log.Println("LOGS :", logs)
return logs, nil
}