Accessor for each ressource to access DB
This commit is contained in:
33
processing_mongo_accessor.go
Normal file
33
processing_mongo_accessor.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package oclib
|
||||
|
||||
type ProcessingMongoAccessor struct{
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (pma *ProcessingMongoAccessor) StoreOne(processing Processing) string {
|
||||
|
||||
id, err := StoreOne(processing,"processing")
|
||||
if err != nil{
|
||||
l := CreateLogger("oclib","")
|
||||
l.Error().Msg("Could not store " + processing.Name + " to db. Error: " + err.Error())
|
||||
return ""
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func (pma *ProcessingMongoAccessor) LoadOne(id string) Processing {
|
||||
|
||||
var processing Processing
|
||||
|
||||
res_mongo, err := LoadOne(id,"processing")
|
||||
if err != nil{
|
||||
l := CreateLogger("oclib","")
|
||||
l.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
|
||||
return Processing{}
|
||||
}
|
||||
|
||||
res_mongo.Decode(&processing)
|
||||
|
||||
return processing
|
||||
}
|
||||
Reference in New Issue
Block a user