search items
This commit is contained in:
parent
3c4d48fdc7
commit
5d5f95725f
4 changed files with 32 additions and 6 deletions
|
|
@ -60,6 +60,7 @@ type ItemFilter struct {
|
|||
FolderID *int64
|
||||
FeedID *int64
|
||||
Status *ItemStatus
|
||||
Search *string
|
||||
}
|
||||
|
||||
func (s *Storage) CreateItems(items []Item) bool {
|
||||
|
|
@ -112,6 +113,16 @@ func listQueryPredicate(filter ItemFilter) (string, []interface{}) {
|
|||
cond = append(cond, "i.status = ?")
|
||||
args = append(args, *filter.Status)
|
||||
}
|
||||
if filter.Search != nil {
|
||||
words := strings.Fields(*filter.Search)
|
||||
terms := make([]string, len(words))
|
||||
for idx, word := range words {
|
||||
terms[idx] = word + "*"
|
||||
}
|
||||
|
||||
cond = append(cond, "i.search_rowid in (select rowid from search where search match ?)")
|
||||
args = append(args, strings.Join(terms, " "))
|
||||
}
|
||||
|
||||
predicate := "1"
|
||||
if len(cond) > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue