diff --git a/Modifiers.md b/Modifiers.md index 33226bc..135b4fb 100644 --- a/Modifiers.md +++ b/Modifiers.md @@ -9,7 +9,22 @@ A KSQL modifier is a special tag you can add to any of the attributes of your st KSQL comes with a few built-in Modifiers and an API for creating your own modifiers if necessary. These will be discussed in more detail in the next sections. -Applying a Modifier to a struct attribute will cause KSQL to use this modifier when Inserting, Updating and Querying that field. +Here is an example of how a `User` struct might look like when using some of these modifiers: + +```golang +type User struct { + ID uint `ksql:"id"` + Name string `ksql:"name"` + Age int `ksql:"age"` + + Address Address `ksql:"address,json"` + + UpdatedAt time.Time `ksql:"updated_at,timeNowUTC"` + CreatedAt time.Time `ksql:"created_at,timeNowUTC/skipUpdates"` +} +``` + +Applying a Modifier to a struct attribute will cause KSQL to use this modifier when Inserting, Updating, and Querying that field. A Modifier can therefore be used for: @@ -31,21 +46,6 @@ Modifiers improve on the `Valuer`/`Scanner` feature provided by the standard lib - `skipUpdates`: Will ignore fields on updates. - `skipInserts`: Will ignore fields on inserts. -Here is an example of how a `User` struct might look like using some of these modifiers: - -```golang -type user struct { - ID uint `ksql:"id"` - Name string `ksql:"name"` - Age int `ksql:"age"` - - Address Address `ksql:"address,json"` - - UpdatedAt time.Time `ksql:"updated_at,timeNowUTC"` - CreatedAt time.Time `ksql:"created_at,timeNowUTC/skipUpdates"` -} -``` - ### Registering new Modifiers Registering a new Modifier is simple: Describe it using an instance of `ksqlmodifiers.AttrModifier` and register it on KSQL by calling the global function: `ksqlmodifiers.RegisterAttrModifier` as illustrated below: