Refactor to use aerogo/database

This commit is contained in:
2017-10-27 09:11:56 +02:00
parent c0d7b0d2df
commit b07a98ed32
18 changed files with 52 additions and 164 deletions

View File

@ -22,14 +22,13 @@ func Get(ctx *aero.Context) string {
}
// Fetch posts
postObjects, getErr := arn.DB.GetMany("Post", thread.Posts)
postObjects := arn.DB.GetMany("Post", thread.Posts)
posts := make([]*arn.Post, len(postObjects), len(postObjects))
if getErr != nil {
return ctx.Error(http.StatusInternalServerError, "Could not retrieve posts", getErr)
for i, obj := range postObjects {
posts[i] = obj.(*arn.Post)
}
posts := postObjects.([]*arn.Post)
// Sort posts
arn.SortPostsLatestLast(posts)