Eugh.
the build was successful

This commit is contained in:
2019-05-16 15:57:22 +02:00
parent 7e3dc49635
commit a5410dff2c
30 changed files with 177 additions and 118 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ import (
)
// Add adds a new chapter.
func Add(story models.Story, title, author, source string, createdDate time.Time, finctionalDate *time.Time, commentMode models.ChapterCommentMode) (models.Chapter, error) {
func Add(story models.Story, title, author, source string, createdDate time.Time, finctionalDate *time.Time, commentMode models.ChapterCommentMode) (*models.Chapter, error) {
chapter := models.Chapter{
ID: makeChapterID(),
StoryID: story.ID,
@@ -27,7 +27,7 @@ func Add(story models.Story, title, author, source string, createdDate time.Time
err := collection.Insert(chapter)
if err != nil {
return models.Chapter{}, err
return nil, err
}
if createdDate.After(story.UpdatedDate) {
@@ -36,5 +36,5 @@ func Add(story models.Story, title, author, source string, createdDate time.Time
}
}
return chapter, nil
return &chapter, nil
}
+5 -2
View File
@@ -13,11 +13,14 @@ import (
var collection *mgo.Collection
var storyCollection *mgo.Collection
func find(query interface{}) (models.Chapter, error) {
func find(query interface{}) (*models.Chapter, error) {
chapter := models.Chapter{}
err := collection.Find(query).One(&chapter)
if err != nil {
return nil, err
}
return chapter, err
return &chapter, err
}
func list(query interface{}) ([]models.Chapter, error) {
+3 -3
View File
@@ -9,7 +9,7 @@ import (
// Edit edits a chapter, and updates EditedDate. While many Edit functions cheat if there's nothing to
// change, this functill will due to EditedDate.
func Edit(chapter models.Chapter, title, source *string, fictionalDate *time.Time, commentMode *models.ChapterCommentMode, commentsLocked *bool) (models.Chapter, error) {
func Edit(chapter models.Chapter, title, source *string, fictionalDate *time.Time, commentMode *models.ChapterCommentMode, commentsLocked *bool) (*models.Chapter, error) {
now := time.Now()
changes := bson.M{"editedDate": now}
@@ -39,8 +39,8 @@ func Edit(chapter models.Chapter, title, source *string, fictionalDate *time.Tim
err := collection.UpdateId(chapter.ID, bson.M{"$set": changes})
if err != nil {
return chapter, err
return nil, err
}
return edited, nil
return &edited, nil
}
+1 -1
View File
@@ -6,6 +6,6 @@ import (
)
// FindID finds a chapter by ID
func FindID(id string) (models.Chapter, error) {
func FindID(id string) (*models.Chapter, error) {
return find(bson.M{"_id": id})
}
+3 -3
View File
@@ -8,12 +8,12 @@ import (
)
// Move updates the chapter, moving it to the given story.
func Move(chapter models.Chapter, story models.Story) (models.Chapter, error) {
func Move(chapter models.Chapter, story models.Story) (*models.Chapter, error) {
now := time.Now()
err := collection.UpdateId(chapter.ID, bson.M{"$set": bson.M{"editedDate": now, "storyId": story.ID}})
if err != nil {
return models.Chapter{}, err
return nil, err
}
chapter.EditedDate = now
@@ -24,5 +24,5 @@ func Move(chapter models.Chapter, story models.Story) (models.Chapter, error) {
}
}
return chapter, nil
return &chapter, nil
}
+2 -2
View File
@@ -6,9 +6,9 @@ import (
)
// Remove removes a chapter.
func Remove(chapter models.Chapter) (models.Chapter, error) {
func Remove(chapter models.Chapter) (*models.Chapter, error) {
if err := collection.RemoveId(chapter.ID); err != nil {
return models.Chapter{}, err
return nil, err
}
return chapter, nil