Пример #1
0
// NewIDType create new instance of id type
func NewIDType(attrs map[string]string) types.CustomType {
	var ptr *int64
	return &abstracttype.SimpleCustomType{
		MetaType: &abstracttype.MetaType{
			SQLTypeName:  "int primary key",
			HTMLTypeName: "number",
			GoTypeRef:    reflect.TypeOf(ptr).Elem(),
			Attributes:   attrs,
		},
		TypeConverter: abstracttype.NewInt64Converter(),
		TypeValidator: validator.NewNoValidator(),
	}
}
Пример #2
0
// NewContentType create new instance of content type with custom attributes
func NewContentType(attrs map[string]string) types.CustomType {
	var ptr *string
	return &abstracttype.SimpleCustomType{
		MetaType: &abstracttype.MetaType{
			SQLTypeName:  "text",
			HTMLTypeName: "text",
			GoTypeRef:    reflect.TypeOf(ptr).Elem(),
			Attributes:   attrs,
		},
		TypeConverter: abstracttype.NewStringConverter(),
		TypeValidator: validator.NewNoValidator(),
	}
}
Пример #3
0
// NewFileType create new instance of a file type
func NewFileType(attrs map[string]string, fs filesystem.Filespace) types.CustomType {
	var ptr *types.File
	return &abstracttype.SimpleCustomType{
		MetaType: &abstracttype.MetaType{
			SQLTypeName:  "varchar(500)",
			HTMLTypeName: "file",
			GoTypeRef:    reflect.TypeOf(ptr).Elem(),
			Attributes:   attrs,
		},
		TypeConverter: abstracttype.NewFilespaceConverter(fs),
		TypeValidator: validator.NewNoValidator(),
	}
}
Пример #4
0
func NewTestCustomType() types.CustomType {
	var ptr *string
	return &SimpleCustomType{
		MetaType: &MetaType{
			SQLTypeName:  "varchar(100)",
			HTMLTypeName: "text",
			GoTypeRef:    reflect.TypeOf(ptr).Elem(),
			Attributes:   make(map[string]string),
		},
		TypeConverter: NewStringConverter(),
		TypeValidator: validator.NewNoValidator(),
	}
}