Documentation ¶
Index ¶
- func HasKey(column string, opts ...Option) *sql.Predicate
- func LenEQ(column string, size int, opts ...Option) *sql.Predicate
- func LenGT(column string, size int, opts ...Option) *sql.Predicate
- func LenGTE(column string, size int, opts ...Option) *sql.Predicate
- func LenLT(column string, size int, opts ...Option) *sql.Predicate
- func LenLTE(column string, size int, opts ...Option) *sql.Predicate
- func LenNEQ(column string, size int, opts ...Option) *sql.Predicate
- func LenPath(b *sql.Builder, column string, opts ...Option)
- func ParsePath(dotpath string) ([]string, error)
- func ValueContains(column string, arg interface{}, opts ...Option) *sql.Predicate
- func ValueEQ(column string, arg interface{}, opts ...Option) *sql.Predicate
- func ValueGT(column string, arg interface{}, opts ...Option) *sql.Predicate
- func ValueGTE(column string, arg interface{}, opts ...Option) *sql.Predicate
- func ValueLT(column string, arg interface{}, opts ...Option) *sql.Predicate
- func ValueLTE(column string, arg interface{}, opts ...Option) *sql.Predicate
- func ValueNEQ(column string, arg interface{}, opts ...Option) *sql.Predicate
- func ValuePath(b *sql.Builder, column string, opts ...Option)
- type Option
- type PathOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasKey ¶
HasKey return a predicate for checking that a JSON key exists and not NULL.
sqljson.HasKey("column", sql.DotPath("a.b[2].c"))
func LenEQ ¶
LenEQ return a predicate for checking that an array length of a JSON (returned by the path) is equal to the given argument.
sqljson.LenEQ("a", 1, sqljson.Path("b"))
func LenGT ¶
LenGT return a predicate for checking that an array length of a JSON (returned by the path) is greater than the given argument.
sqljson.LenGT("a", 1, sqljson.Path("b"))
func LenGTE ¶
LenGTE return a predicate for checking that an array length of a JSON (returned by the path) is greater than or equal to the given argument.
sqljson.LenGTE("a", 1, sqljson.Path("b"))
func LenLT ¶
LenLT return a predicate for checking that an array length of a JSON (returned by the path) is less than the given argument.
sqljson.LenLT("a", 1, sqljson.Path("b"))
func LenLTE ¶
LenLTE return a predicate for checking that an array length of a JSON (returned by the path) is less than or equal to the given argument.
sqljson.LenLTE("a", 1, sqljson.Path("b"))
func LenNEQ ¶
LenNEQ return a predicate for checking that an array length of a JSON (returned by the path) is not equal to the given argument.
sqljson.LenEQ("a", 1, sqljson.Path("b"))
func LenPath ¶
LenPath writes to the given SQL builder the JSON path for getting the length of a given JSON path.
sqljson.LenPath(b, Path("a", "b", "[1]", "c"))
func ParsePath ¶
ParsePath parses the "dotpath" for the DotPath option.
"a.b" => ["a", "b"] "a[1][2]" => ["a", "[1]", "[2]"] "a.\"b.c\" => ["a", "\"b.c\""]
func ValueContains ¶
ValueContains return a predicate for checking that a JSON value (returned by the path) contains the given argument.
sqljson.ValueContains("a", 1, sqljson.Path("b"))
func ValueEQ ¶
ValueEQ return a predicate for checking that a JSON value (returned by the path) is equal to the given argument.
sqljson.ValueEQ("a", 1, sqljson.Path("b"))
func ValueGT ¶
ValueGT return a predicate for checking that a JSON value (returned by the path) is greater than the given argument.
sqljson.ValueGT("a", 1, sqljson.Path("b"))
func ValueGTE ¶
ValueGTE return a predicate for checking that a JSON value (returned by the path) is greater than or equal to the given argument.
sqljson.ValueGTE("a", 1, sqljson.Path("b"))
func ValueLT ¶
ValueLT return a predicate for checking that a JSON value (returned by the path) is less than the given argument.
sqljson.ValueLT("a", 1, sqljson.Path("b"))
func ValueLTE ¶
ValueLTE return a predicate for checking that a JSON value (returned by the path) is less than or equal to the given argument.
sqljson.ValueLTE("a", 1, sqljson.Path("b"))
Types ¶
type Option ¶
type Option func(*PathOptions)
Option allows for calling database JSON paths with functional options.
func Cast ¶
Cast indicates that the result value should be casted to the given type.
ValuePath(b, "column", Path("a", "b", "[1]", "c"), Cast("int"))
func DotPath ¶
DotPath is similar to Path, but accepts string with dot format.
ValuePath(b, "column", DotPath("a.b.c")) ValuePath(b, "column", DotPath("a.b[2].c"))
Note that DotPath is ignored if the input is invalid.