graph2: Added removal of chapters upon story being deleted.
the build failed

This commit is contained in:
2018-09-23 13:53:13 +02:00
parent cd1f122502
commit 815f30597e
2 changed files with 25 additions and 2 deletions
+13 -1
View File
@@ -1,6 +1,9 @@
package chapters
import "git.aiterp.net/rpdata/api/models"
import (
"git.aiterp.net/rpdata/api/models"
"github.com/globalsign/mgo/bson"
)
// Remove removes a chapter.
func Remove(chapter models.Chapter) (models.Chapter, error) {
@@ -10,3 +13,12 @@ func Remove(chapter models.Chapter) (models.Chapter, error) {
return chapter, nil
}
// RemoveStory removes all chapters belonging to a story
func RemoveStory(story models.Story) error {
if _, err := collection.RemoveAll(bson.M{"storyId": story.ID}); err != nil {
return err
}
return nil
}