feat: implement search multi tags

This commit is contained in:
Steven
2024-07-26 08:40:40 +08:00
parent c6a09d9353
commit edc3b578d6
14 changed files with 61 additions and 35 deletions

View File

@ -81,8 +81,10 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if v.Raw != nil {
where, args = append(where, "memo.payload = "+placeholder(len(args)+1)), append(args, *v.Raw)
}
if v.Tag != nil {
where, args = append(where, "memo.payload->'property'->'tags' @> "+placeholder(len(args)+1)), append(args, fmt.Sprintf(`["%s"]`, *v.Tag))
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))
}
}
if v.HasLink {
where = append(where, "(memo.payload->'property'->>'hasLink')::BOOLEAN IS TRUE")