👔 Update search post include range

This commit is contained in:
LittleSheep 2024-10-16 21:01:17 +08:00
parent 9bb55f10ce
commit 89b495577e

View File

@ -99,7 +99,10 @@ func FilterPostDraft(tx *gorm.DB) *gorm.DB {
func FilterPostWithFuzzySearch(tx *gorm.DB, probe string) *gorm.DB { func FilterPostWithFuzzySearch(tx *gorm.DB, probe string) *gorm.DB {
probe = "%" + probe + "%" probe = "%" + probe + "%"
return tx.Where("? AND body->>'content' ILIKE ?", gorm.Expr("body ? 'content'"), probe) return tx.
Where("? AND body->>'content' ILIKE ?", gorm.Expr("body ? 'content'"), probe).
Or("? AND body->>'title' ILIKE ?", gorm.Expr("body ? 'title'"), probe).
Or("? AND body->>'description' ILIKE ?", gorm.Expr("body ? 'description'"), probe)
} }
func PreloadGeneral(tx *gorm.DB) *gorm.DB { func PreloadGeneral(tx *gorm.DB) *gorm.DB {