config pb

This commit is contained in:
mr 2024-07-22 09:16:59 +02:00
parent 53811538c0
commit 742bcd1acf

View File

@ -26,6 +26,7 @@ func (d LibDataEnum) EnumIndex() int {
type LibData struct { type LibData struct {
Data utils.DBObject `bson:"data" json:"data"` Data utils.DBObject `bson:"data" json:"data"`
Code int `bson:"code" json:"code"`
Err error `bson:"error" json:"error"` Err error `bson:"error" json:"error"`
} }
@ -40,22 +41,28 @@ func GetLogger() zerolog.Logger {
} }
func LoadOne(collection LibDataEnum, id string) LibData { func LoadOne(collection LibDataEnum, id string) LibData {
d, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id) d, code, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
return LibData{Data: d, Err: err} return LibData{Data: d, Code: code, Err: err}
} }
func UpdateOne(collection LibDataEnum, set map[string]interface{}, id string) LibData { func UpdateOne(collection LibDataEnum, set map[string]interface{}, id string) LibData {
d, err := models.Model(collection.EnumIndex()).GetAccessor().UpdateOne(set, id) d, code, err := models.Model(collection.EnumIndex()).GetAccessor().UpdateOne(set, id)
return LibData{Data: d, Err: err} return LibData{Data: d, Code: code, Err: err}
} }
func DeleteOne(collection LibDataEnum, id string) LibData { func DeleteOne(collection LibDataEnum, id string) LibData {
d, err := models.Model(collection.EnumIndex()).GetAccessor().DeleteOne(id) d, code, err := models.Model(collection.EnumIndex()).GetAccessor().DeleteOne(id)
return LibData{Data: d, Err: err} return LibData{Data: d, Code: code, Err: err}
} }
func StoreOne(collection LibDataEnum, object map[string]interface{}) LibData { func StoreOne(collection LibDataEnum, object map[string]interface{}) LibData {
model := models.Model(collection.EnumIndex()) model := models.Model(collection.EnumIndex())
d, err := model.GetAccessor().StoreOne(model.Deserialize(object)) d, code, err := model.GetAccessor().StoreOne(model.Deserialize(object))
return LibData{Data: d, Err: err} return LibData{Data: d, Code: code, Err: err}
} }
func CopyOne(collection LibDataEnum, object map[string]interface{}) LibData {
model := models.Model(collection.EnumIndex())
d, code, err := model.GetAccessor().CopyOne(model.Deserialize(object))
return LibData{Data: d, Code: code, Err: err}
}