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

@@ -82,8 +82,10 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if v.Raw != nil {
where, args = append(where, "`memo`.`payload` = ?"), append(args, *v.Raw)
}
if v.Tag != nil {
where, args = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.tags') LIKE ?"), append(args, fmt.Sprintf(`%%"%s"%%`, *v.Tag))
if len(v.TagSearch) != 0 {
for _, tag := range v.TagSearch {
where, args = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.tags') LIKE ?"), append(args, fmt.Sprintf(`%%"%s"%%`, tag))
}
}
if v.HasLink {
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.hasLink') IS TRUE")