data

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

README

Shared structure and basic repo

Documentation

Index

Constants

View Source
const BoolKind = "bool"
View Source
const DoubleKind = "double"
View Source
const FloatKind = "float"
View Source
const IntKind = "int"
View Source
const JsonKind = "json"
View Source
const LongKind = "long"
View Source
const NullKind = "null"
View Source
const StringKind = "string"

Variables

View Source
var File_data_address_proto protoreflect.FileDescriptor
View Source
var File_data_data_proto protoreflect.FileDescriptor

Functions

func ParseSort

func ParseSort(fields []string) string

Types

type Address added in v0.0.2

type Address struct {

	//Country or region
	Country string `protobuf:"bytes,1,opt,name=country,proto3" json:"country,omitempty"`
	//State or province
	State     string `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"`
	City      string `protobuf:"bytes,3,opt,name=city,proto3" json:"city,omitempty"`
	ZipCode   string `protobuf:"bytes,4,opt,name=zip_code,json=zipCode,proto3" json:"zip_code,omitempty"`
	Line1     string `protobuf:"bytes,5,opt,name=line1,proto3" json:"line1,omitempty"`
	Line2     string `protobuf:"bytes,6,opt,name=line2,proto3" json:"line2,omitempty"`
	Line3     string `protobuf:"bytes,7,opt,name=line3,proto3" json:"line3,omitempty"`
	Longitude string `protobuf:"bytes,8,opt,name=longitude,proto3" json:"longitude,omitempty"`
	Latitude  string `protobuf:"bytes,9,opt,name=latitude,proto3" json:"latitude,omitempty"`
	// contains filtered or unexported fields
}

func (*Address) Descriptor deprecated added in v0.0.2

func (*Address) Descriptor() ([]byte, []int)

Deprecated: Use Address.ProtoReflect.Descriptor instead.

func (*Address) GetCity added in v0.0.2

func (x *Address) GetCity() string

func (*Address) GetCountry added in v0.0.2

func (x *Address) GetCountry() string

func (*Address) GetLatitude added in v0.0.2

func (x *Address) GetLatitude() string

func (*Address) GetLine1 added in v0.0.2

func (x *Address) GetLine1() string

func (*Address) GetLine2 added in v0.0.2

func (x *Address) GetLine2() string

func (*Address) GetLine3 added in v0.0.2

func (x *Address) GetLine3() string

func (*Address) GetLongitude added in v0.0.2

func (x *Address) GetLongitude() string

func (*Address) GetState added in v0.0.2

func (x *Address) GetState() string

func (*Address) GetZipCode added in v0.0.2

func (x *Address) GetZipCode() string

func (*Address) ProtoMessage added in v0.0.2

func (*Address) ProtoMessage()

func (*Address) ProtoReflect added in v0.0.2

func (x *Address) ProtoReflect() protoreflect.Message

func (*Address) Reset added in v0.0.2

func (x *Address) Reset()

func (*Address) String added in v0.0.2

func (x *Address) String() string

type AddressEntity added in v0.0.2

type AddressEntity struct {
	//Country or region
	Country string
	//State or province
	State   string
	City    string
	ZipCode string
	Line1   string
	Line2   string
	Line3   string
	//TODO database geo?
	Longitude string
	//TODO database geo?
	Latitude string
}

func NewAddressEntityFromPb added in v0.0.2

func NewAddressEntityFromPb(s *Address) *AddressEntity

func (*AddressEntity) ToPb added in v0.0.2

func (s *AddressEntity) ToPb() *Address

type AfterCreate added in v0.0.2

type AfterCreate[TEntity any] struct {
	Entity TEntity
}

func NewAfterCreate added in v0.0.2

func NewAfterCreate[TEntity any](entity TEntity) *AfterCreate[TEntity]

type AfterDelete added in v0.0.2

type AfterDelete[TEntity any] struct {
	Entity TEntity
}

func NewAfterDelete added in v0.0.2

func NewAfterDelete[TEntity any](entity TEntity) *AfterDelete[TEntity]

type AfterUpdate added in v0.0.2

type AfterUpdate[TEntity any] struct {
	Entity TEntity
}

func NewAfterUpdate added in v0.0.2

func NewAfterUpdate[TEntity any](entity TEntity) *AfterUpdate[TEntity]

type BeforeCreate added in v0.0.2

type BeforeCreate[TEntity any] struct {
	Entity TEntity
}

func NewBeforeCreate added in v0.0.2

func NewBeforeCreate[TEntity any](entity TEntity) *BeforeCreate[TEntity]

type BeforeDelete added in v0.0.2

type BeforeDelete[TEntity any] struct {
	Entity TEntity
}

func NewBeforeDelete added in v0.0.2

func NewBeforeDelete[TEntity any](entity TEntity) *BeforeDelete[TEntity]

type BeforeUpdate added in v0.0.2

type BeforeUpdate[TEntity any] struct {
	Entity TEntity
	P      query.Select
}

func NewBeforeUpdate added in v0.0.2

func NewBeforeUpdate[TEntity any](entity TEntity) *BeforeUpdate[TEntity]

type DynamicValue added in v0.0.2

type DynamicValue struct {

	// Types that are assignable to Value:
	//	*DynamicValue_IntValue
	//	*DynamicValue_LongValue
	//	*DynamicValue_FloatValue
	//	*DynamicValue_DoubleValue
	//	*DynamicValue_StringValue
	//	*DynamicValue_BoolValue
	//	*DynamicValue_NullValue
	//	*DynamicValue_JsonValue
	Value isDynamicValue_Value `protobuf_oneof:"value"`
	// contains filtered or unexported fields
}

func (*DynamicValue) Descriptor deprecated added in v0.0.2

func (*DynamicValue) Descriptor() ([]byte, []int)

Deprecated: Use DynamicValue.ProtoReflect.Descriptor instead.

func (*DynamicValue) GetBoolValue added in v0.0.2

func (x *DynamicValue) GetBoolValue() bool

func (*DynamicValue) GetDoubleValue added in v0.0.2

func (x *DynamicValue) GetDoubleValue() float64

func (*DynamicValue) GetFloatValue added in v0.0.2

func (x *DynamicValue) GetFloatValue() float32

func (*DynamicValue) GetIntValue added in v0.0.2

func (x *DynamicValue) GetIntValue() int32

func (*DynamicValue) GetJsonValue added in v0.0.2

func (x *DynamicValue) GetJsonValue() *structpb.Struct

func (*DynamicValue) GetLongValue added in v0.0.2

func (x *DynamicValue) GetLongValue() int64

func (*DynamicValue) GetNullValue added in v0.0.2

func (x *DynamicValue) GetNullValue() structpb.NullValue

func (*DynamicValue) GetStringValue added in v0.0.2

func (x *DynamicValue) GetStringValue() string

func (*DynamicValue) GetValue added in v0.0.2

func (m *DynamicValue) GetValue() isDynamicValue_Value

func (*DynamicValue) ProtoMessage added in v0.0.2

func (*DynamicValue) ProtoMessage()

func (*DynamicValue) ProtoReflect added in v0.0.2

func (x *DynamicValue) ProtoReflect() protoreflect.Message

func (*DynamicValue) Reset added in v0.0.2

func (x *DynamicValue) Reset()

func (*DynamicValue) String added in v0.0.2

func (x *DynamicValue) String() string

type DynamicValueFilter added in v0.0.2

type DynamicValueFilter struct {

	// Types that are assignable to Filter:
	//	*DynamicValueFilter_IntValue
	//	*DynamicValueFilter_LongValue
	//	*DynamicValueFilter_FloatValue
	//	*DynamicValueFilter_DoubleValue
	//	*DynamicValueFilter_StringValue
	//	*DynamicValueFilter_BoolValue
	//	*DynamicValueFilter_NullValue
	Filter isDynamicValueFilter_Filter `protobuf_oneof:"filter"`
	// contains filtered or unexported fields
}

func (*DynamicValueFilter) Descriptor deprecated added in v0.0.2

func (*DynamicValueFilter) Descriptor() ([]byte, []int)

Deprecated: Use DynamicValueFilter.ProtoReflect.Descriptor instead.

func (*DynamicValueFilter) GetBoolValue added in v0.0.2

func (x *DynamicValueFilter) GetBoolValue() *query.BooleanFilterOperators

func (*DynamicValueFilter) GetDoubleValue added in v0.0.2

func (x *DynamicValueFilter) GetDoubleValue() *query.DoubleFilterOperators

func (*DynamicValueFilter) GetFilter added in v0.0.2

func (m *DynamicValueFilter) GetFilter() isDynamicValueFilter_Filter

func (*DynamicValueFilter) GetFloatValue added in v0.0.2

func (x *DynamicValueFilter) GetFloatValue() *query.FloatFilterOperators

func (*DynamicValueFilter) GetIntValue added in v0.0.2

func (x *DynamicValueFilter) GetIntValue() *query.Int32FilterOperators

func (*DynamicValueFilter) GetLongValue added in v0.0.2

func (x *DynamicValueFilter) GetLongValue() *query.Int64FilterOperators

func (*DynamicValueFilter) GetNullValue added in v0.0.2

func (x *DynamicValueFilter) GetNullValue() *query.NullFilterOperators

func (*DynamicValueFilter) GetStringValue added in v0.0.2

func (x *DynamicValueFilter) GetStringValue() *query.StringFilterOperation

func (*DynamicValueFilter) ProtoMessage added in v0.0.2

func (*DynamicValueFilter) ProtoMessage()

func (*DynamicValueFilter) ProtoReflect added in v0.0.2

func (x *DynamicValueFilter) ProtoReflect() protoreflect.Message

func (*DynamicValueFilter) Reset added in v0.0.2

func (x *DynamicValueFilter) Reset()

func (*DynamicValueFilter) String added in v0.0.2

func (x *DynamicValueFilter) String() string

type DynamicValueFilter_BoolValue added in v0.0.2

type DynamicValueFilter_BoolValue struct {
	BoolValue *query.BooleanFilterOperators `protobuf:"bytes,7,opt,name=bool_value,json=boolValue,proto3,oneof"`
}

type DynamicValueFilter_DoubleValue added in v0.0.2

type DynamicValueFilter_DoubleValue struct {
	DoubleValue *query.DoubleFilterOperators `protobuf:"bytes,5,opt,name=double_value,json=doubleValue,proto3,oneof"`
}

type DynamicValueFilter_FloatValue added in v0.0.2

type DynamicValueFilter_FloatValue struct {
	FloatValue *query.FloatFilterOperators `protobuf:"bytes,4,opt,name=float_value,json=floatValue,proto3,oneof"`
}

type DynamicValueFilter_IntValue added in v0.0.2

type DynamicValueFilter_IntValue struct {
	IntValue *query.Int32FilterOperators `protobuf:"bytes,2,opt,name=int_value,json=intValue,proto3,oneof"`
}

type DynamicValueFilter_LongValue added in v0.0.2

type DynamicValueFilter_LongValue struct {
	LongValue *query.Int64FilterOperators `protobuf:"bytes,3,opt,name=long_value,json=longValue,proto3,oneof"`
}

type DynamicValueFilter_NullValue added in v0.0.2

type DynamicValueFilter_NullValue struct {
	NullValue *query.NullFilterOperators `protobuf:"bytes,8,opt,name=null_value,json=nullValue,proto3,oneof"`
}

type DynamicValueFilter_StringValue added in v0.0.2

type DynamicValueFilter_StringValue struct {
	StringValue *query.StringFilterOperation `protobuf:"bytes,6,opt,name=string_value,json=stringValue,proto3,oneof"`
}

type DynamicValue_BoolValue added in v0.0.2

type DynamicValue_BoolValue struct {
	BoolValue bool `protobuf:"varint,7,opt,name=bool_value,json=boolValue,proto3,oneof"`
}

type DynamicValue_DoubleValue added in v0.0.2

type DynamicValue_DoubleValue struct {
	DoubleValue float64 `protobuf:"fixed64,5,opt,name=double_value,json=doubleValue,proto3,oneof"`
}

type DynamicValue_FloatValue added in v0.0.2

type DynamicValue_FloatValue struct {
	FloatValue float32 `protobuf:"fixed32,4,opt,name=float_value,json=floatValue,proto3,oneof"`
}

type DynamicValue_IntValue added in v0.0.2

type DynamicValue_IntValue struct {
	IntValue int32 `protobuf:"varint,2,opt,name=int_value,json=intValue,proto3,oneof"`
}

type DynamicValue_JsonValue added in v0.0.2

type DynamicValue_JsonValue struct {
	JsonValue *structpb.Struct `protobuf:"bytes,9,opt,name=json_value,json=jsonValue,proto3,oneof"`
}

type DynamicValue_LongValue added in v0.0.2

type DynamicValue_LongValue struct {
	LongValue int64 `protobuf:"varint,3,opt,name=long_value,json=longValue,proto3,oneof"`
}

type DynamicValue_NullValue added in v0.0.2

type DynamicValue_NullValue struct {
	NullValue structpb.NullValue `protobuf:"varint,8,opt,name=null_value,json=nullValue,proto3,enum=google.protobuf.NullValue,oneof"`
}

type DynamicValue_StringValue added in v0.0.2

type DynamicValue_StringValue struct {
	StringValue string `protobuf:"bytes,6,opt,name=string_value,json=stringValue,proto3,oneof"`
}

type JSONMap added in v0.0.2

type JSONMap map[string]interface{}

JSONMap defiend JSON data type, need to implements driver.Valuer, sql.Scanner interface

func (JSONMap) GormDBDataType added in v0.0.2

func (JSONMap) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (JSONMap) GormDataType added in v0.0.2

func (m JSONMap) GormDataType() string

GormDataType gorm common data type

func (JSONMap) GormValue added in v0.0.2

func (m JSONMap) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (JSONMap) MarshalJSON added in v0.0.2

func (m JSONMap) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*JSONMap) Scan added in v0.0.2

func (m *JSONMap) Scan(val interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*JSONMap) UnmarshalJSON added in v0.0.2

func (m *JSONMap) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (JSONMap) Value added in v0.0.2

func (m JSONMap) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Repo added in v0.0.2

type Repo[TEntity any, TKey any, TQuery any] interface {
	List(ctx context.Context, query *TQuery) ([]*TEntity, error)
	First(ctx context.Context, query *TQuery) (*TEntity, error)
	Count(ctx context.Context, query *TQuery) (total int64, filtered int64, err error)
	Get(ctx context.Context, id TKey) (*TEntity, error)
	Create(ctx context.Context, entity *TEntity) error
	BatchCreate(ctx context.Context, entity []*TEntity, batchSize int) error
	Update(ctx context.Context, id TKey, entity *TEntity, p query.Select) error
	Upsert(ctx context.Context, entity *TEntity) error
	Delete(ctx context.Context, id TKey) error
}

type SortOpt

type SortOpt struct {
	Field  string
	IsDesc bool
}

func ParseSortIntoOpt

func ParseSortIntoOpt(fields []string) []*SortOpt

type Value

type Value struct {
	// which kind of data, can be "null","int","long","float","double","string","bool"
	Kind        string
	IntValue    int32
	LongValue   int64
	FloatValue  float32
	DoubleValue float64
	StringValue string
	BoolValue   bool
	JsonValue   JSONMap
}

Value represents dynamic field which is friendly for database

func NewFromDynamicValue added in v0.0.2

func NewFromDynamicValue(v *DynamicValue) *Value

func (*Value) GetNativeValue added in v0.0.2

func (v *Value) GetNativeValue() interface{}

func (*Value) RunIfBool

func (v *Value) RunIfBool(f func(v bool))

func (*Value) RunIfDouble

func (v *Value) RunIfDouble(f func(v float64))

func (*Value) RunIfFloat

func (v *Value) RunIfFloat(f func(v float32))

func (*Value) RunIfInt

func (v *Value) RunIfInt(f func(v int32))

func (*Value) RunIfJson added in v0.0.2

func (v *Value) RunIfJson(f func(v map[string]interface{}))

func (*Value) RunIfLong

func (v *Value) RunIfLong(f func(v int64))

func (*Value) RunIfNull

func (v *Value) RunIfNull(f func())

func (*Value) RunIfString

func (v *Value) RunIfString(f func(v string))

func (*Value) SetAsBool

func (v *Value) SetAsBool(value bool)

func (*Value) SetAsDouble

func (v *Value) SetAsDouble(value float64)

func (*Value) SetAsFloat

func (v *Value) SetAsFloat(value float32)

func (*Value) SetAsInt

func (v *Value) SetAsInt(value int32)

func (*Value) SetAsJson added in v0.0.2

func (v *Value) SetAsJson(value map[string]interface{})

func (*Value) SetAsLong

func (v *Value) SetAsLong(value int64)

func (*Value) SetAsNull

func (v *Value) SetAsNull()

func (*Value) SetAsString

func (v *Value) SetAsString(value string)

func (*Value) ToDynamicValue added in v0.0.2

func (v *Value) ToDynamicValue() *DynamicValue

func (*Value) ToStructPb added in v0.0.2

func (v *Value) ToStructPb() *structpb.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL