Shallow Get All
This commit is contained in:
@@ -24,6 +24,12 @@ func (d LibDataEnum) EnumIndex() int {
|
||||
return int(d)
|
||||
}
|
||||
|
||||
type LibDataShallow struct {
|
||||
Data []utils.ShallowDBObject `bson:"data" json:"data"`
|
||||
Code int `bson:"code" json:"code"`
|
||||
Err string `bson:"error" json:"error"`
|
||||
}
|
||||
|
||||
type LibData struct {
|
||||
Data utils.DBObject `bson:"data" json:"data"`
|
||||
Code int `bson:"code" json:"code"`
|
||||
@@ -40,6 +46,14 @@ func GetLogger() zerolog.Logger {
|
||||
return logs.GetLogger()
|
||||
}
|
||||
|
||||
func LoadAll(collection LibDataEnum) LibDataShallow {
|
||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().LoadAll()
|
||||
if err != nil {
|
||||
return LibDataShallow{Data: d, Code: code, Err: err.Error()}
|
||||
}
|
||||
return LibDataShallow{Data: d, Code: code}
|
||||
}
|
||||
|
||||
func LoadOne(collection LibDataEnum, id string) LibData {
|
||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user