Begin PIS implementation
This commit is contained in:
26
dbAccess/pis.go
Normal file
26
dbAccess/pis.go
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user