timetable-mgr/dbAccess/pis.go
Fred Boniface 90e8fd5649
All checks were successful
Go Test / test (push) Successful in 2m3s
Begin PIS implementation
2024-05-02 15:35:00 +01:00

27 lines
568 B
Go

package dbAccess
import (
"context"
"errors"
"git.fjla.uk/owlboard/go-types/pkg/database"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
func GetPisMetadata() (*database.PisMetadata, error) {
coll := MongoClient.Database(DatabaseName).Collection(MetaCollection)
filter := bson.M{"type": "PisMetadata"}
var result database.PisMetadata
err := coll.FindOne(context.Background(), filter).Decode(&result)
if err != nil {
if errors.Is(err, mongo.ErrNoDocuments) {
return nil, nil
}
return nil, err
}
return &result, nil
}