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.
 
 

51 lines
1.0 KiB

package models
import "time"
// A Post is a part of a log file.
type Post struct {
ID string `bson:"_id"`
LogID string `bson:"logId"`
Time time.Time `bson:"time"`
Kind string `bson:"kind"`
Nick string `bson:"nick"`
Text string `bson:"text"`
Position int `bson:"position"`
}
func (post *Post) ApplyUpdate(update PostUpdate) {
if update.Time != nil {
post.Time = *update.Time
}
if update.Kind != nil {
post.Kind = *update.Kind
}
if update.Nick != nil {
post.Nick = *update.Nick
}
if update.Text != nil {
post.Text = *update.Text
}
}
// IsChangeObject is an interface implementation to identify it as a valid
// ChangeObject in GQL.
func (*Post) IsChangeObject() {
panic("this method is a dummy, and so is its caller")
}
// PostFilter is used to generate a query to the database.
type PostFilter struct {
IDs []string
Kinds []string
LogID *string
Search *string
Limit int
}
type PostUpdate struct {
Time *time.Time
Kind *string
Nick *string
Text *string
}