33 lines
610 B
Go
33 lines
610 B
Go
package oclib
|
|
|
|
type DataMongoAccessor struct{
|
|
|
|
}
|
|
|
|
|
|
func (dma *DataMongoAccessor) StoreOne(data Data) string {
|
|
|
|
id, err := StoreOne(data,"data")
|
|
if err != nil{
|
|
l := CreateLogger("oclib","")
|
|
l.Error().Msg("Could not store " + data.Name + " to db. Error: " + err.Error())
|
|
return ""
|
|
}
|
|
return id
|
|
}
|
|
|
|
func (dma *DataMongoAccessor) LoadOne(id string) Data {
|
|
|
|
var data Data
|
|
|
|
res_mongo, err := LoadOne(id,"data")
|
|
if err != nil{
|
|
l := CreateLogger("oclib","")
|
|
l.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
|
|
return Data{}
|
|
}
|
|
|
|
res_mongo.Decode(&data)
|
|
|
|
return data
|
|
} |