mirror of https://github.com/stashapp/stash.git
52 lines
855 B
Go
52 lines
855 B
Go
package tag
|
|
|
|
import "github.com/stashapp/stash/pkg/models"
|
|
|
|
func ByName(qb models.TagReader, name string) (*models.Tag, error) {
|
|
f := &models.TagFilterType{
|
|
Name: &models.StringCriterionInput{
|
|
Value: name,
|
|
Modifier: models.CriterionModifierEquals,
|
|
},
|
|
}
|
|
|
|
pp := 1
|
|
ret, count, err := qb.Query(f, &models.FindFilterType{
|
|
PerPage: &pp,
|
|
})
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if count > 0 {
|
|
return ret[0], nil
|
|
}
|
|
|
|
return nil, nil
|
|
}
|
|
|
|
func ByAlias(qb models.TagReader, alias string) (*models.Tag, error) {
|
|
f := &models.TagFilterType{
|
|
Aliases: &models.StringCriterionInput{
|
|
Value: alias,
|
|
Modifier: models.CriterionModifierEquals,
|
|
},
|
|
}
|
|
|
|
pp := 1
|
|
ret, count, err := qb.Query(f, &models.FindFilterType{
|
|
PerPage: &pp,
|
|
})
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if count > 0 {
|
|
return ret[0], nil
|
|
}
|
|
|
|
return nil, nil
|
|
}
|