From 6d0dc451e45effc8cbb6953a766b111036d893ce Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 4 Jul 2018 22:05:19 -0700 Subject: Add search form --- storage/entry_pagination_builder.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'storage') diff --git a/storage/entry_pagination_builder.go b/storage/entry_pagination_builder.go index 72fae8d..e443b00 100644 --- a/storage/entry_pagination_builder.go +++ b/storage/entry_pagination_builder.go @@ -23,6 +23,14 @@ type EntryPaginationBuilder struct { direction string } +// WithSearchQuery adds full-text search query to the condition. +func (e *EntryPaginationBuilder) WithSearchQuery(query string) { + if query != "" { + e.conditions = append(e.conditions, fmt.Sprintf("e.document_vectors @@ plainto_tsquery($%d)", len(e.args)+1)) + e.args = append(e.args, query) + } +} + // WithStarred adds starred to the condition. func (e *EntryPaginationBuilder) WithStarred() { e.conditions = append(e.conditions, "e.starred is true") -- cgit v1.2.3