Templates for the "gnorm" database management engine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

103 lines
2.5 KiB

// Code generated by gnorm, DO NOT EDIT!
package {{.Params.RootPkg}}
import (
"github.com/lib/pq"
uuid "github.com/satori/go.uuid"
)
{{ range (makeSlice "Bytes" "Jsonb" "int" "string" "sql.NullString" "int64" "sql.NullInt64" "float64" "sql.NullFloat64" "bool" "sql.NullBool" "time.Time" "pq.NullTime" "uint32" "uuid.UUID" "uuid.NullUUID" "hstore.Hstore") }}
{{ $fieldName := title (replace . "." "" 1) }}
// {{$fieldName}}Field is a component that returns a WhereClause that contains a
// comparison based on its field and a strongly typed value.
type {{$fieldName}}Field string
// Equals returns a WhereClause for this field.
func (f {{$fieldName}}Field) Equals(v {{.}}) WhereClause {
return Where{
Field: string(f),
Comp: CompEqual,
Value: v,
}
}
// GreaterThan returns a WhereClause for this field.
func (f {{$fieldName}}Field) GreaterThan(v {{.}}) WhereClause {
return Where{
Field: string(f),
Comp: CompGreater,
Value: v,
}
}
// LessThan returns a WhereClause for this field.
func (f {{$fieldName}}Field) LessThan(v {{.}}) WhereClause {
return Where{
Field: string(f),
Comp: CompLess,
Value: v,
}
}
// GreaterOrEqual returns a WhereClause for this field.
func (f {{$fieldName}}Field) GreaterOrEqual(v {{.}}) WhereClause {
return Where{
Field: string(f),
Comp: CompGTE,
Value: v,
}
}
// LessOrEqual returns a WhereClause for this field.
func (f {{$fieldName}}Field) LessOrEqual(v {{.}}) WhereClause {
return Where{
Field: string(f),
Comp: CompLTE,
Value: v,
}
}
// NotEqual returns a WhereClause for this field.
func (f {{$fieldName}}Field) NotEqual(v {{.}}) WhereClause {
return Where{
Field: string(f),
Comp: CompNE,
Value: v,
}
}
// In returns a WhereClause for this field.
func (f {{$fieldName}}Field) In(vals []{{.}}) WhereClause {
values := make([]interface{}, len(vals))
for x := range vals {
values[x] = vals[x]
}
return InClause{
Field: string(f),
Vals: values,
}
}
{{end}}
{{ range (makeSlice "Jsonb" "sql.NullString" "sql.NullInt64" "sql.NullFloat64" "sql.NullBool" "pq.NullTime" "uuid.NullUUID") }}
{{ $fieldName := title (replace . "." "" 1) }}
// IsNull returns a WhereClause that matches when this field is NULL.
func (f {{$fieldName}}Field) IsNull() WhereClause {
return NullClause{
Field: string(f),
Null: true,
}
}
// IsNotNull returns a WhereClause that matches when this field is not NULL.
func (f {{$fieldName}}Field) IsNotNull() WhereClause {
return NullClause{
Field: string(f),
Null: false,
}
}
{{end}}