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.

30 lines
665 B

  1. package stories
  2. import (
  3. "time"
  4. "git.aiterp.net/rpdata/api/models"
  5. )
  6. // Add creates a new story.
  7. func Add(name, author string, category models.StoryCategory, listed, open bool, tags []models.Tag, createdDate, fictionalDate time.Time) (models.Story, error) {
  8. story := models.Story{
  9. ID: makeStoryID(),
  10. Name: name,
  11. Author: author,
  12. Category: category,
  13. Listed: listed,
  14. Open: open,
  15. Tags: tags,
  16. CreatedDate: createdDate,
  17. FictionalDate: fictionalDate,
  18. UpdatedDate: createdDate,
  19. }
  20. err := collection.Insert(story)
  21. if err != nil {
  22. return models.Story{}, err
  23. }
  24. return story, nil
  25. }