package changes import ( "time" "git.aiterp.net/rpdata/api/models" "github.com/globalsign/mgo/bson" ) // Filter is a filter for changes.List. type Filter struct { Keys []models.ChangeKey EarliestDate *time.Time Limit *int } // List lists changes. func List(filter *Filter) ([]models.Change, error) { query := bson.M{} limit := 0 if filter != nil { if filter.Limit != nil { limit = *filter.Limit } if filter.Keys != nil { query["keys"] = bson.M{"$in": filter.Keys} } else { query["listed"] = true } if filter.EarliestDate != nil { query["date"] = bson.M{"$gte": *filter.EarliestDate} } } else { query["listed"] = true limit = 256 } return list(query, limit) }