Documentation ¶
Overview ¶
Package query contains helpful code for building structured search queries. The contents of this package are about making the query logic easier to read, by providing helpers for building the underlying search proto buffer expressions.
Index ¶
- type Builder
- func Bool(value bool) Builder
- func Double(value float64) Builder
- func Expression(e *search.Expression) Builder
- func Name(name string) Builder
- func Not(rhs Builder) Builder
- func Signed(value int64) Builder
- func String(value string) Builder
- func Unsigned(value uint64) Builder
- func Value(value interface{}) Builder
- func (lhs Builder) And(rhs Builder) Builder
- func (lhs Builder) Equal(rhs Builder) Builder
- func (b Builder) Expression() *search.Expression
- func (lhs Builder) Greater(rhs Builder) Builder
- func (lhs Builder) GreaterOrEqual(rhs Builder) Builder
- func (lhs Builder) Less(rhs Builder) Builder
- func (lhs Builder) LessOrEqual(rhs Builder) Builder
- func (object Builder) Member(name string) Builder
- func (lhs Builder) Or(rhs Builder) Builder
- func (b Builder) Query() *search.Query
- func (value Builder) Regex(pattern string) Builder
- func (b Builder) Replace(match Builder, expr Builder) Builder
- func (b Builder) Set(name string, value interface{}) Builder
- func (value Builder) Subscript(key Builder) Builder
- func (b Builder) Using(name string) func(interface{}) Builder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is the type used to allow fluent construction of search queries.
func Expression ¶
func Expression(e *search.Expression) Builder
Expression creates a builder from a search expression.
func Value ¶
func Value(value interface{}) Builder
Value creates a builder from a value. The type of expression will be inferred from the type of the value.
func (Builder) Expression ¶
func (b Builder) Expression() *search.Expression
Expression returns the content of the builder as a search expression.
func (Builder) Greater ¶
Greater builds a search expression that tests whether the lhs is greater than the rhs.
func (Builder) GreaterOrEqual ¶
GreaterOrEqual builds a search expression that tests whether the lhs is greater than or equal to the rhs.
func (Builder) Less ¶
Less builds a search expression that tests whether the lhs is less than the rhs.
func (Builder) LessOrEqual ¶
LessOrEqual builds a search expression that tests whether the lhs is less than or equal to the rhs.
func (Builder) Member ¶
Member builds a search expression that looks up the named member of the object.
func (Builder) Regex ¶
Regex builds a search expression that tests whether value matches the supplied regex pattern.
func (Builder) Set ¶
Set is a small helper on top of Replace for the common case of identifier substitution. name is a top level identifier to replace, and Value(value) is the expression to replace it with.
func (Builder) Subscript ¶
Subscript builds a search expression that applies the key as a subscript to the value.
func (Builder) Using ¶
Using returns a function that when invoked returns a copy of b with Name(name) replace by Value(value). This is to make the common case of single value substitutions into precompiles queries easy. To use it
var myQuery = script.MustCompile("Object.Name == $V").Using("$V") myService.Search(myQuery(nameToFind).Query())