config pb
This commit is contained in:
parent
53811538c0
commit
742bcd1acf
@ -26,6 +26,7 @@ func (d LibDataEnum) EnumIndex() int {
|
||||
|
||||
type LibData struct {
|
||||
Data utils.DBObject `bson:"data" json:"data"`
|
||||
Code int `bson:"code" json:"code"`
|
||||
Err error `bson:"error" json:"error"`
|
||||
}
|
||||
|
||||
@ -40,22 +41,28 @@ func GetLogger() zerolog.Logger {
|
||||
}
|
||||
|
||||
func LoadOne(collection LibDataEnum, id string) LibData {
|
||||
d, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
|
||||
return LibData{Data: d, Err: err}
|
||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
|
||||
return LibData{Data: d, Code: code, Err: err}
|
||||
}
|
||||
|
||||
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}
|
||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().UpdateOne(set, id)
|
||||
return LibData{Data: d, Code: code, Err: err}
|
||||
}
|
||||
|
||||
func DeleteOne(collection LibDataEnum, id string) LibData {
|
||||
d, err := models.Model(collection.EnumIndex()).GetAccessor().DeleteOne(id)
|
||||
return LibData{Data: d, Err: err}
|
||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().DeleteOne(id)
|
||||
return LibData{Data: d, Code: code, Err: err}
|
||||
}
|
||||
|
||||
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}
|
||||
d, code, err := model.GetAccessor().StoreOne(model.Deserialize(object))
|
||||
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}
|
||||
}
|
Loading…
Reference in New Issue
Block a user