oc-lib/storage_mongo_accessor.go

33 lines
669 B
Go
Raw Normal View History

package oclib
type StorageMongoAccessor struct{
}
func (schedulema *StorageMongoAccessor) StoreOne(storage Storage) string {
id, err := StoreOne(storage,"storage")
if err != nil{
l := CreateLogger("oclib","")
l.Error().Msg("Could not store " + storage.Name + " to db. Error: " + err.Error())
return ""
}
return id
}
func (schedulema *StorageMongoAccessor) LoadOne(id string) Storage {
var storage Storage
res_mongo, err := LoadOne(id,"storage")
if err != nil{
l := CreateLogger("oclib","")
l.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return Storage{}
}
res_mongo.Decode(&storage)
return storage
}