data

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 17 Imported by: 3 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

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

Deprecated: Use Address.ProtoReflect.Descriptor instead.

func (*Address) GetCity

func (x *Address) GetCity() string

func (*Address) GetCountry

func (x *Address) GetCountry() string

func (*Address) GetLatitude

func (x *Address) GetLatitude() string

func (*Address) GetLine1

func (x *Address) GetLine1() string

func (*Address) GetLine2

func (x *Address) GetLine2() string

func (*Address) GetLine3

func (x *Address) GetLine3() string

func (*Address) GetLongitude

func (x *Address) GetLongitude() string

func (*Address) GetState

func (x *Address) GetState() string

func (*Address) GetZipCode

func (x *Address) GetZipCode() string

func (*Address) ProtoMessage

func (*Address) ProtoMessage()

func (*Address) ProtoReflect

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

func (*Address) Reset

func (x *Address) Reset()

func (*Address) String

func (x *Address) String() string

type AddressEntity

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

func NewAddressEntityFromPb(s *Address) *AddressEntity

func (*AddressEntity) ToPb

func (s *AddressEntity) ToPb() *Address

type AfterCreate

type AfterCreate[TEntity any] struct {
	Entity TEntity
}

func NewAfterCreate

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

type AfterDelete

type AfterDelete[TEntity any] struct {
	Entity TEntity
}

func NewAfterDelete

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

type AfterUpdate

type AfterUpdate[TEntity any] struct {
	Entity TEntity
}

func NewAfterUpdate

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

type BeforeCreate

type BeforeCreate[TEntity any] struct {
	Entity TEntity
}

func NewBeforeCreate

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

type BeforeDelete

type BeforeDelete[TEntity any] struct {
	Entity TEntity
}

func NewBeforeDelete

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

type BeforeUpdate

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

func NewBeforeUpdate

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

type DynamicValue

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

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

Deprecated: Use DynamicValue.ProtoReflect.Descriptor instead.

func (*DynamicValue) GetBoolValue

func (x *DynamicValue) GetBoolValue() bool

func (*DynamicValue) GetDoubleValue

func (x *DynamicValue) GetDoubleValue() float64

func (*DynamicValue) GetFloatValue

func (x *DynamicValue) GetFloatValue() float32

func (*DynamicValue) GetIntValue

func (x *DynamicValue) GetIntValue() int32

func (*DynamicValue) GetJsonValue

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

func (*DynamicValue) GetLongValue

func (x *DynamicValue) GetLongValue() int64

func (*DynamicValue) GetNullValue

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

func (*DynamicValue) GetStringValue

func (x *DynamicValue) GetStringValue() string

func (*DynamicValue) GetValue

func (m *DynamicValue) GetValue() isDynamicValue_Value

func (*DynamicValue) ProtoMessage

func (*DynamicValue) ProtoMessage()

func (*DynamicValue) ProtoReflect

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

func (*DynamicValue) Reset

func (x *DynamicValue) Reset()

func (*DynamicValue) String

func (x *DynamicValue) String() string

type DynamicValueFilter

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

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

Deprecated: Use DynamicValueFilter.ProtoReflect.Descriptor instead.

func (*DynamicValueFilter) GetBoolValue

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

func (*DynamicValueFilter) GetDoubleValue

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

func (*DynamicValueFilter) GetFilter

func (m *DynamicValueFilter) GetFilter() isDynamicValueFilter_Filter

func (*DynamicValueFilter) GetFloatValue

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

func (*DynamicValueFilter) GetIntValue

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

func (*DynamicValueFilter) GetLongValue

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

func (*DynamicValueFilter) GetNullValue

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

func (*DynamicValueFilter) GetStringValue

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

func (*DynamicValueFilter) ProtoMessage

func (*DynamicValueFilter) ProtoMessage()

func (*DynamicValueFilter) ProtoReflect

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

func (*DynamicValueFilter) Reset

func (x *DynamicValueFilter) Reset()

func (*DynamicValueFilter) String

func (x *DynamicValueFilter) String() string

type DynamicValueFilter_BoolValue

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

type DynamicValueFilter_DoubleValue

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

type DynamicValueFilter_FloatValue

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

type DynamicValueFilter_IntValue

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

type DynamicValueFilter_LongValue

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

type DynamicValueFilter_NullValue

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

type DynamicValueFilter_StringValue

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

type DynamicValue_BoolValue

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

type DynamicValue_DoubleValue

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

type DynamicValue_FloatValue

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

type DynamicValue_IntValue

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

type DynamicValue_JsonValue

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

type DynamicValue_LongValue

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

type DynamicValue_NullValue

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

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

type JSONMap

type JSONMap map[string]interface{}

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

func (JSONMap) GormDBDataType

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

GormDBDataType gorm db data type

func (JSONMap) GormDataType

func (m JSONMap) GormDataType() string

GormDataType gorm common data type

func (JSONMap) GormValue

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

func (JSONMap) MarshalJSON

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

MarshalJSON to output non base64 encoded []byte

func (*JSONMap) Scan

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

Scan scan value into Jsonb, implements sql.Scanner interface

func (*JSONMap) UnmarshalJSON

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

UnmarshalJSON to deserialize []byte

func (JSONMap) Value

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

Value return json value, implement driver.Valuer interface

type Repo

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

func NewFromDynamicValue(v *DynamicValue) *Value

func (*Value) GetNativeValue

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

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

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

func (v *Value) ToDynamicValue() *DynamicValue

func (*Value) ToStructPb

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

Jump to

Keyboard shortcuts

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