snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
19
tag/suggest.go
Normal file
19
tag/suggest.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package tag
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/traggo/server/auth"
|
||||
"github.com/traggo/server/generated/gqlmodel"
|
||||
"github.com/traggo/server/model"
|
||||
)
|
||||
|
||||
// SuggestTag suggests a tag.
|
||||
func (r *ResolverForTag) SuggestTag(ctx context.Context, query string) ([]*gqlmodel.TagDefinition, error) {
|
||||
var suggestions []model.TagDefinition
|
||||
find := r.DB.Where("user_id = ?", auth.GetUser(ctx).ID).Where("Key LIKE ?", query+"%").Find(&suggestions)
|
||||
var result []*gqlmodel.TagDefinition
|
||||
copier.Copy(&result, &suggestions)
|
||||
return result, find.Error
|
||||
}
|
||||
Reference in New Issue
Block a user