chore: update tag search

This commit is contained in:
Steven
2024-09-23 21:41:23 +08:00
parent 171a89564e
commit 8b444be6ca
4 changed files with 7 additions and 7 deletions

View File

@ -83,7 +83,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
}
if len(v.TagSearch) != 0 {
for _, tag := range v.TagSearch {
where, args = append(where, "memo.payload->'property'->'tags' @> "+placeholder(len(args)+1)), append(args, fmt.Sprintf(`["%s"]`, tag))
where, args = append(where, "EXISTS (SELECT 1 FROM jsonb_array_elements(memo.payload->'property'->'tags') AS tag WHERE tag::text = "+placeholder(len(args)+1)+" OR tag::text LIKE "+placeholder(len(args)+2)+")"), append(args, fmt.Sprintf(`"%s"`, tag), fmt.Sprintf(`"%s/%%"`, tag))
}
}
if v.HasLink {