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.
 
 

74 lines
2.2 KiB

package models
import "time"
// A Story is user content that does not have a wiki-suitable format. Documents, new stories, short stories, and so on.
// The story model is a container for multiple chapters this time, in contrast to the previous version.
type Story struct {
ID string `bson:"_id"`
Author string `bson:"author"`
Name string `bson:"name"`
Category StoryCategory `bson:"category"`
Open bool `bson:"open"`
Listed bool `bson:"listed"`
Tags []Tag `bson:"tags"`
CreatedDate time.Time `bson:"createdDate"`
FictionalDate time.Time `bson:"fictionalDate,omitempty"`
UpdatedDate time.Time `bson:"updatedDate"`
SortByFictionalDate bool `bson:"sortByFictionalDate"`
}
func (story *Story) ApplyUpdate(update StoryUpdate) {
if update.Name != nil {
story.Name = *update.Name
}
if update.Category != nil {
story.Category = *update.Category
}
if update.Author != nil {
story.Author = *update.Author
}
if update.Open != nil {
story.Open = *update.Open
}
if update.Listed != nil {
story.Listed = *update.Listed
}
if update.SortByFictionalDate != nil {
story.SortByFictionalDate = *update.SortByFictionalDate
}
if update.FictionalDate != nil {
story.FictionalDate = *update.FictionalDate
}
if update.UpdatedDate != nil {
story.UpdatedDate = *update.UpdatedDate
}
}
// IsChangeObject is an interface implementation to identify it as a valid
// ChangeObject in GQL.
func (_ *Story) IsChangeObject() {
panic("this method is a dummy, and so is its caller")
}
type StoryFilter struct {
Author *string
Tags []Tag
EarliestFictionalDate time.Time
LatestFictionalDate time.Time
Category *StoryCategory
Open *bool
Unlisted *bool
Limit int
}
type StoryUpdate struct {
Name *string
Category *StoryCategory
Author *string
Open *bool
Listed *bool
FictionalDate *time.Time
UpdatedDate *time.Time
SortByFictionalDate *bool
}