GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
506 B

5 years ago
5 years ago
  1. package chapters
  2. import (
  3. "git.aiterp.net/rpdata/api/models"
  4. "github.com/globalsign/mgo/bson"
  5. )
  6. // Remove removes a chapter.
  7. func Remove(chapter models.Chapter) (*models.Chapter, error) {
  8. if err := collection.RemoveId(chapter.ID); err != nil {
  9. return nil, err
  10. }
  11. return chapter, nil
  12. }
  13. // RemoveStory removes all chapters belonging to a story
  14. func RemoveStory(story models.Story) error {
  15. if _, err := collection.RemoveAll(bson.M{"storyId": story.ID}); err != nil {
  16. return err
  17. }
  18. return nil
  19. }