Fixed nil deref error on no filter, fixed no results
the build was successful

This commit is contained in:
2018-08-01 14:51:45 +02:00
parent 132cf28f0f
commit c348a90b70
2 changed files with 9 additions and 4 deletions
+5 -3
View File
@@ -193,14 +193,14 @@ func FindID(id string) (Story, error) {
}
// List lists stories by any non-zero criteria passed with it.
func List(author string, category *string, tags []Tag, earliest, latest time.Time, unlisted bool, open *bool, limit int) ([]Story, error) {
func List(author string, category string, tags []Tag, earliest, latest time.Time, unlisted bool, open *bool, limit int) ([]Story, error) {
query := bson.M{}
if author != "" {
query["author"] = author
}
if category != nil {
if category != "" {
query["category"] = category
}
@@ -223,7 +223,9 @@ func List(author string, category *string, tags []Tag, earliest, latest time.Tim
}
}
query["unlisted"] = unlisted
if unlisted {
query["listed"] = false
}
if open != nil {
query["open"] = *open