Skip to content

Commit 05ad904

Browse files
committed
Updated results type and struct field names
1 parent ab2c9f3 commit 05ad904

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

server/category.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99
)
1010

1111
// GetCats - Retrieve a category from the database
12-
func GetCats(collection *mongo.Collection, id int, token string) *Category {
12+
func GetCats(collection *mongo.Collection, id int, token string) Category {
1313
// if !validToken(token) {
1414
// return nil
1515
// }
1616

17-
var result *Category
17+
var result Category
1818
filter := bson.D{{"categoryID", id}}
1919

2020
// Find a category

server/post.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
)
1212

1313
// GetPosts - Retrieve a post from the database
14-
func GetPosts(collection *mongo.Collection, id int, category string) *Post {
15-
var result *Post
14+
func GetPosts(collection *mongo.Collection, id int, category string) Post {
15+
var result Post
1616

1717
// Search for post by id and category
1818
filter := bson.D{{"postID", id}, {"category", category}}
@@ -64,19 +64,19 @@ func GetAllPosts(collection *mongo.Collection, count int, cat string) []*Post {
6464

6565
// NewPosts - Add a new post
6666
func NewPosts(collection *mongo.Collection, id int, category int, showInMenu bool, title string, subtitle string, postType string, content string, github string, fb string) {
67-
currtime := time.Now()
67+
currTime := time.Now()
6868
post := Post{
69-
postID: id,
70-
postTitle: title,
71-
postSubtitle: subtitle,
72-
postType: postType,
73-
postCategory: category,
74-
createdOn: currtime.Unix(),
75-
lastEditedOn: currtime.Unix(),
76-
postContent: content,
77-
postLinkGithub: github,
78-
postLinkFacebook: fb,
79-
showInMenu: showInMenu,
69+
PostID: id,
70+
PostTitle: title,
71+
PostSubtitle: subtitle,
72+
PostType: postType,
73+
PostCategory: category,
74+
CreatedOn: currTime.Unix(),
75+
LastEditedOn: currTime.Unix(),
76+
PostContent: content,
77+
PostLinkGithub: github,
78+
PostLinkFacebook: fb,
79+
ShowInMenu: showInMenu,
8080
}
8181

8282
_, err := collection.InsertOne(context.TODO(), post)

server/server.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ type H map[string]interface{}
1919

2020
// Post - struct to contain post data
2121
type Post struct {
22-
postID int
23-
postTitle string
24-
postSubtitle string
25-
postType string
26-
postCategory int
27-
createdOn int64
28-
lastEditedOn int64
29-
postContent string
30-
postLinkGithub string
31-
postLinkFacebook string
32-
showInMenu bool
22+
PostID int
23+
PostTitle string
24+
PostSubtitle string
25+
PostType string
26+
PostCategory int
27+
CreatedOn int64
28+
LastEditedOn int64
29+
PostContent string
30+
PostLinkGithub string
31+
PostLinkFacebook string
32+
ShowInMenu bool
3333
}
3434

3535
// Category - struct to contain category data
@@ -119,10 +119,10 @@ func serveAPI(e *echo.Echo) {
119119
// e.POST("/login/", login(userCollection))
120120

121121
// Routes for posts
122-
e.GET("/posts/:id/", getPosts(postsCollection))
122+
e.GET("/posts/", getPosts(postsCollection))
123123
e.POST("/post/", newPosts(postsCollection))
124-
e.PUT("/post/:id/", updatePosts(postsCollection))
125-
e.DELETE("/post/:id/", deletePosts(postsCollection))
124+
e.PUT("/post/", updatePosts(postsCollection))
125+
e.DELETE("/post/", deletePosts(postsCollection))
126126

127127
// Routes for categories
128128
e.GET("/category/:id/", getCats(catCollection))

server/sponsor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
)
1212

1313
// GetSponsors - Retrieve a sponsor from the database
14-
func GetSponsors(collection *mongo.Collection, id string, token string) *Sponsor {
14+
func GetSponsors(collection *mongo.Collection, id string, token string) Sponsor {
1515
parsedID := uuid.Must(uuid.Parse(id))
1616

17-
var result *Sponsor
17+
var result Sponsor
1818
filter := bson.D{{"sponsorID", parsedID}}
1919
err := collection.FindOne(context.TODO(), filter).Decode(&result)
2020
if err != nil {

0 commit comments

Comments
 (0)