Refactor to use aerogo/database
This commit is contained in:
@ -48,11 +48,7 @@ func Select(ctx *aero.Context) string {
|
||||
Results: []interface{}{},
|
||||
}
|
||||
|
||||
stream, err := arn.DB.All(dataTypeName)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Error fetching data from the database", err)
|
||||
}
|
||||
stream := arn.DB.All(dataTypeName)
|
||||
|
||||
process := func(obj interface{}) {
|
||||
_, _, value, _ := mirror.GetField(obj, field)
|
||||
@ -62,47 +58,8 @@ func Select(ctx *aero.Context) string {
|
||||
}
|
||||
}
|
||||
|
||||
switch dataTypeName {
|
||||
case "Analytics":
|
||||
for obj := range stream.(chan *arn.Analytics) {
|
||||
process(obj)
|
||||
}
|
||||
case "Anime":
|
||||
for obj := range stream.(chan *arn.Anime) {
|
||||
process(obj)
|
||||
}
|
||||
case "AnimeList":
|
||||
for obj := range stream.(chan *arn.AnimeList) {
|
||||
process(obj)
|
||||
}
|
||||
case "Character":
|
||||
for obj := range stream.(chan *arn.Character) {
|
||||
process(obj)
|
||||
}
|
||||
case "Group":
|
||||
for obj := range stream.(chan *arn.Group) {
|
||||
process(obj)
|
||||
}
|
||||
case "Post":
|
||||
for obj := range stream.(chan *arn.Post) {
|
||||
process(obj)
|
||||
}
|
||||
case "Settings":
|
||||
for obj := range stream.(chan *arn.Settings) {
|
||||
process(obj)
|
||||
}
|
||||
case "SoundTrack":
|
||||
for obj := range stream.(chan *arn.SoundTrack) {
|
||||
process(obj)
|
||||
}
|
||||
case "Thread":
|
||||
for obj := range stream.(chan *arn.Thread) {
|
||||
process(obj)
|
||||
}
|
||||
case "User":
|
||||
for obj := range stream.(chan *arn.User) {
|
||||
process(obj)
|
||||
}
|
||||
for obj := range stream {
|
||||
process(obj)
|
||||
}
|
||||
|
||||
for _, obj := range response.Results {
|
||||
|
Reference in New Issue
Block a user