Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(config CharacterConfig, opts ...Option) gorm.Plugin
New creates a new instance of the plugin that can be registered in gorm. Without any settings, all queries will be LIKE-d.
Example ¶
db, _ := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{}) config := CharacterConfig{ GreaterThanPrefix: ">", GreaterOrEqualToPrefix: ">=", LessThanPrefix: "<", LessOrEqualToPrefix: "<=", NotEqualToPrefix: "!=", LikePrefix: "~", NotLikePrefix: "!~", } _ = db.Use(New(config)) _ = db.Use(New(config, SettingOnly()))
Output:
Types ¶
type CharacterConfig ¶
type CharacterConfig struct { GreaterThanPrefix string GreaterOrEqualToPrefix string LessThanPrefix string LessOrEqualToPrefix string NotEqualToPrefix string LikePrefix string NotLikePrefix string }
CharacterConfig must be provided to indicate when a field must be changed, these should all be prefixes
type Option ¶
type Option func(like *gormQonvert)
Option can be given to the New() method to tweak its behaviour
func SettingOnly ¶
func SettingOnly() Option
SettingOnly makes it so that only queries with the setting 'gormQonvert' set to true can be turned into LIKE queries. This can be configured using db.Set("gormQonvert", true) on the query.
Click to show internal directories.
Click to hide internal directories.