main logger
This commit is contained in:
@@ -2,6 +2,7 @@ package oclib
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||
"cloud.o-forge.io/core/oc-lib/logs"
|
||||
"cloud.o-forge.io/core/oc-lib/models"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
@@ -27,27 +28,29 @@ type LibData struct {
|
||||
Err error `bson:"error" json:"error"`
|
||||
}
|
||||
|
||||
func Init() {
|
||||
func Init(appName string) {
|
||||
logs.SetAppName(appName)
|
||||
logs.SetLogger(logs.CreateLogger("main", ""))
|
||||
mongo.MONGOService.Init(models.GetModelsNames(), GetConfig())
|
||||
}
|
||||
|
||||
func LoadOne(col LibDataEnum, id string) LibData {
|
||||
d, err := models.Model(col.EnumIndex()).GetAccessor().LoadOne(id)
|
||||
func LoadOne(collection LibDataEnum, id string) LibData {
|
||||
d, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
|
||||
return LibData{Data: d, Err: err}
|
||||
}
|
||||
|
||||
func UpdateOne(col LibDataEnum, set map[string]interface{}, id string) LibData {
|
||||
d, err := models.Model(col.EnumIndex()).GetAccessor().UpdateOne(set, id)
|
||||
func UpdateOne(collection LibDataEnum, set map[string]interface{}, id string) LibData {
|
||||
d, err := models.Model(collection.EnumIndex()).GetAccessor().UpdateOne(set, id)
|
||||
return LibData{Data: d, Err: err}
|
||||
}
|
||||
|
||||
func DeleteOne(col LibDataEnum, id string) LibData {
|
||||
d, err := models.Model(col.EnumIndex()).GetAccessor().DeleteOne(id)
|
||||
func DeleteOne(collection LibDataEnum, id string) LibData {
|
||||
d, err := models.Model(collection.EnumIndex()).GetAccessor().DeleteOne(id)
|
||||
return LibData{Data: d, Err: err}
|
||||
}
|
||||
|
||||
func StoreOne(col LibDataEnum, object map[string]interface{}) LibData {
|
||||
model := models.Model(col.EnumIndex())
|
||||
func StoreOne(collection LibDataEnum, object map[string]interface{}) LibData {
|
||||
model := models.Model(collection.EnumIndex())
|
||||
d, err := model.GetAccessor().StoreOne(model.Deserialize(object))
|
||||
return LibData{Data: d, Err: err}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user