Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateConditions(_ *cobra.Command, args []string)
- type CodeGenerator
- type Condition
- type ConditionsGenerator
- type Field
- func (field Field) ChangeType(newType types.Type, fromPointer bool) Field
- func (field Field) CompleteName() string
- func (field Field) GetType() types.Type
- func (field Field) IsModelID() bool
- func (field Field) IsNullable() bool
- func (field Field) IsUpdatable() bool
- func (field Field) TypeName() string
- func (field Field) TypeString() string
- type File
- type GormTag
- type GormTags
- type JenParam
- func (param JenParam) GenericType() *jen.Statement
- func (param *JenParam) SQLToBasicType(typeV Type)
- func (param *JenParam) ToBasicKind(basicType *types.Basic)
- func (param *JenParam) ToBool()
- func (param JenParam) ToCustomType(destPkg string, typeV Type)
- func (param *JenParam) ToSlice()
- func (param *JenParam) ToString()
- type RelationGettersGenerator
- type Type
Constants ¶
const (
DestPackageKey = "dest_package"
)
Variables ¶
var ErrFkNotInTypeFields = errors.New("fk not in type's fields")
var GenConditionsCmd = verdeter.BuildVerdeterCommand(verdeter.VerdeterConfig{ Use: "conditions", Short: "Generate conditions to query your objects using cql", Long: `gen is the command you can use to generate conditions to query your objects using cql.`, Run: GenerateConditions, Args: cobra.MinimumNArgs(1), })
Functions ¶
func GenerateConditions ¶
GenConditionsCmd Run func
Types ¶
type CodeGenerator ¶
type Condition ¶
type ConditionsGenerator ¶
type ConditionsGenerator struct {
// contains filtered or unexported fields
}
func NewConditionsGenerator ¶
func NewConditionsGenerator(object types.Object) *ConditionsGenerator
func (ConditionsGenerator) ForEachField ¶
func (cg ConditionsGenerator) ForEachField(file *File, fields []Field) []Condition
Generate the conditions for each of the object's fields
func (ConditionsGenerator) Into ¶
func (cg ConditionsGenerator) Into(file *File) error
Add conditions for an object in the file
type Field ¶
type Field struct { Name string NamePrefix string Type Type Embedded bool Tags GormTags ColumnPrefix string }
func (Field) ChangeType ¶
Create a new field with the same name and tags but a different type
func (Field) CompleteName ¶
func (Field) IsNullable ¶
func (Field) IsUpdatable ¶
func (Field) TypeString ¶
Get field's type full string (pkg + name)
type JenParam ¶
type JenParam struct {
// contains filtered or unexported fields
}
func NewJenParam ¶
func NewJenParam() *JenParam
func (JenParam) GenericType ¶
func (*JenParam) SQLToBasicType ¶
func (*JenParam) ToBasicKind ¶
func (JenParam) ToCustomType ¶
type RelationGettersGenerator ¶
type RelationGettersGenerator struct {
// contains filtered or unexported fields
}
func NewRelationGettersGenerator ¶
func NewRelationGettersGenerator(object types.Object) *RelationGettersGenerator
func (RelationGettersGenerator) ForEachField ¶
func (generator RelationGettersGenerator) ForEachField(file *File, fields []Field) []jen.Code
func (RelationGettersGenerator) Into ¶
func (generator RelationGettersGenerator) Into(file *File) error
Add conditions for an object in the file
type Type ¶
func (Type) CQLModelStruct ¶
Get the struct under type if it is a cql model Returns error if the type is not a cql model
func (Type) GetFK ¶
Returns the fk field of the type to the "field"'s object (another field that references that object)
func (Type) IsGormCustomType ¶
Returns true if the type is a Gorm Custom type (https://gorm.io/docs/data_types.html)
func (Type) IsSQLNullableType ¶
Returns true if the type is a sql nullable type (sql.NullBool, sql.NullInt, etc.)
func (Type) WasPointer ¶
Returns true if the type used to be a pointer (pointers are transformed into the pointed type)