gen
gen copied to clipboard
Custom types
Your Question
Hello I want to create custom type (semver), but I don`t know how can I implement this
package types
import (
"gorm.io/gen/field"
"gorm.io/gorm/clause"
)
type Semver field.String
// Eq ...
func (s Semver) Eq(value string) Semver {
return Semver{field.expr{e: clause.Expr{SQL: "semver_compare(?,'=',?)", Vars: []interface{}{s.RawExpr(), value}}}}
}
The document you expected this should be explained
Expected answer
Please tell me what`s wrong ? (it is posible)
Any ideas ?
The new type Semver will loss all methods from field.String, the embedded type may be your expected