From 5197b070b95c7ba3f7e6bcc8944b6fe5becba293 Mon Sep 17 00:00:00 2001 From: David Stotijn Date: Thu, 27 May 2021 20:50:04 +0200 Subject: [PATCH] Fix faulty search sort type, add consts for sort props --- search.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/search.go b/search.go index 0b2fa54..1182bb6 100644 --- a/search.go +++ b/search.go @@ -7,17 +7,19 @@ import ( type SearchOpts struct { Query string `json:"query,omitempty"` - Sort *SearchFilter `json:"sort,omitempty"` + Sort *SearchSort `json:"sort,omitempty"` Filter *SearchFilter `json:"filter,omitempty"` StartCursor string `json:"start_cursor,omitempty"` PageSize int `json:"page_size,omitempty"` } type SearchSort struct { - Direction SortDirection `json:"direction,omitempty"` - Timestamp string `json:"timestamp"` + Direction SortDirection `json:"direction,omitempty"` + Timestamp SearchSortTimestamp `json:"timestamp"` } +type SearchSortTimestamp string + type SearchFilter struct { Value string `json:"value"` Property string `json:"property"` @@ -32,6 +34,8 @@ type SearchResponse struct { type SearchResults []interface{} +const SearchSortTimestampLastEditedTime SearchSortTimestamp = "last_edited_time" + func (sr *SearchResults) UnmarshalJSON(b []byte) error { rawResults := []json.RawMessage{} err := json.Unmarshal(b, &rawResults)