protodb

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 5 Imported by: 0

README

protodb

db crud base on proto

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FieldDbType_name = map[int32]string{
		0:  "AutoMatch",
		1:  "BOOL",
		2:  "INT32",
		3:  "INT64",
		4:  "FLOAT",
		5:  "DOUBLE",
		6:  "TEXT",
		7:  "JSONB",
		8:  "UUID",
		9:  "TIMESTAMP",
		10: "DATE",
		11: "BYTEA",
		12: "INET",
	}
	FieldDbType_value = map[string]int32{
		"AutoMatch": 0,
		"BOOL":      1,
		"INT32":     2,
		"INT64":     3,
		"FLOAT":     4,
		"DOUBLE":    5,
		"TEXT":      6,
		"JSONB":     7,
		"UUID":      8,
		"TIMESTAMP": 9,
		"DATE":      10,
		"BYTEA":     11,
		"INET":      12,
	}
)

Enum value maps for FieldDbType.

View Source
var (
	// optional protodb.PDBField pdb = 1888;
	E_Pdb = &file_protodb_proto_extTypes[2]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var (
	// optional protodb.PDBFile pdbf = 1888;
	E_Pdbf = &file_protodb_proto_extTypes[0]
)

Extension fields to descriptorpb.FileOptions.

View Source
var (
	// optional protodb.PDBMsg pdbm = 1888;
	E_Pdbm = &file_protodb_proto_extTypes[1]
)

Extension fields to descriptorpb.MessageOptions.

View Source
var File_protodb_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type FieldDbType added in v0.1.3

type FieldDbType int32
const (
	// auto match db type if DbTypeStr not set
	// pb type -> db type
	// bool -> bool
	// string -> text
	// int32 -> int
	// int64,uint32 -> bigint
	// float -> float
	// double -> double precision
	// bytes -> bytea
	FieldDbType_AutoMatch FieldDbType = 0
	FieldDbType_BOOL      FieldDbType = 1
	FieldDbType_INT32     FieldDbType = 2
	FieldDbType_INT64     FieldDbType = 3
	FieldDbType_FLOAT     FieldDbType = 4
	FieldDbType_DOUBLE    FieldDbType = 5
	FieldDbType_TEXT      FieldDbType = 6
	FieldDbType_JSONB     FieldDbType = 7
	FieldDbType_UUID      FieldDbType = 8
	FieldDbType_TIMESTAMP FieldDbType = 9
	FieldDbType_DATE      FieldDbType = 10
	FieldDbType_BYTEA     FieldDbType = 11
	// ipv4 or ipv6 address
	FieldDbType_INET FieldDbType = 12
)

func (FieldDbType) Descriptor added in v0.1.3

func (FieldDbType) Enum added in v0.1.3

func (x FieldDbType) Enum() *FieldDbType

func (FieldDbType) EnumDescriptor deprecated added in v0.1.3

func (FieldDbType) EnumDescriptor() ([]byte, []int)

Deprecated: Use FieldDbType.Descriptor instead.

func (FieldDbType) Number added in v0.1.3

func (x FieldDbType) Number() protoreflect.EnumNumber

func (FieldDbType) String added in v0.1.3

func (x FieldDbType) String() string

func (FieldDbType) Type added in v0.1.3

type PDBField

type PDBField struct {

	// do not generate db field in create table
	// when in update, do not update this field
	NotDB bool `protobuf:"varint,1,opt,name=NotDB,proto3" json:"NotDB,omitempty"`
	// is primary key
	Primary bool `protobuf:"varint,2,opt,name=Primary,proto3" json:"Primary,omitempty"`
	// is unique key
	Unique bool `protobuf:"varint,3,opt,name=Unique,proto3" json:"Unique,omitempty"`
	// is not null
	NotNull bool `protobuf:"varint,4,opt,name=NotNull,proto3" json:"NotNull,omitempty"`
	// reference to other table, sql like:  REFERENCES other_table(other_field)
	Reference string `protobuf:"bytes,5,opt,name=Reference,proto3" json:"Reference,omitempty"`
	// default value
	DefaultValue string `protobuf:"bytes,6,opt,name=DefaultValue,proto3" json:"DefaultValue,omitempty"`
	// append sql before ,
	SQLAppend []string `protobuf:"bytes,7,rep,name=SQLAppend,proto3" json:"SQLAppend,omitempty"`
	// append sql after ,
	SQLAppendsEnd []string `protobuf:"bytes,8,rep,name=SQLAppendsEnd,proto3" json:"SQLAppendsEnd,omitempty"`
	// db no update
	// when in update, do not update this field, for example, create time
	NoUpdate bool `protobuf:"varint,9,opt,name=NoUpdate,proto3" json:"NoUpdate,omitempty"`
	// serial type 0:not serial type 1:smallint 4:int 8:bigint
	// strong advice not use serial type,it's hard in distributed system
	SerialType int32 `protobuf:"varint,10,opt,name=SerialType,proto3" json:"SerialType,omitempty"`
	// db type
	DbType FieldDbType `protobuf:"varint,11,opt,name=DbType,proto3,enum=protodb.FieldDbType" json:"DbType,omitempty"`
	// use custom db type when DbType is not good fit
	DbTypeStr string `protobuf:"bytes,12,opt,name=DbTypeStr,proto3" json:"DbTypeStr,omitempty"`
	// zero value treat as null for insert,update, especially for reference field
	ZeroAsNull bool `protobuf:"varint,13,opt,name=ZeroAsNull,proto3" json:"ZeroAsNull,omitempty"`
	// contains filtered or unexported fields
}

func (*PDBField) Descriptor deprecated

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

Deprecated: Use PDBField.ProtoReflect.Descriptor instead.

func (*PDBField) GetDbType added in v0.1.3

func (x *PDBField) GetDbType() FieldDbType

func (*PDBField) GetDbTypeStr added in v0.1.3

func (x *PDBField) GetDbTypeStr() string

func (*PDBField) GetDefaultValue

func (x *PDBField) GetDefaultValue() string

func (*PDBField) GetNoUpdate

func (x *PDBField) GetNoUpdate() bool

func (*PDBField) GetNotDB

func (x *PDBField) GetNotDB() bool

func (*PDBField) GetNotNull added in v0.1.3

func (x *PDBField) GetNotNull() bool

func (*PDBField) GetPrimary added in v0.1.3

func (x *PDBField) GetPrimary() bool

func (*PDBField) GetReference

func (x *PDBField) GetReference() string

func (*PDBField) GetSQLAppend added in v0.1.3

func (x *PDBField) GetSQLAppend() []string

func (*PDBField) GetSQLAppendsEnd

func (x *PDBField) GetSQLAppendsEnd() []string

func (*PDBField) GetSerialType

func (x *PDBField) GetSerialType() int32

func (*PDBField) GetUnique added in v0.1.3

func (x *PDBField) GetUnique() bool

func (*PDBField) GetZeroAsNull added in v0.1.3

func (x *PDBField) GetZeroAsNull() bool

func (*PDBField) ProtoMessage

func (*PDBField) ProtoMessage()

func (*PDBField) ProtoReflect

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

func (*PDBField) Reset

func (x *PDBField) Reset()

func (*PDBField) String

func (x *PDBField) String() string

type PDBFile

type PDBFile struct {

	// name style(msg & field)
	// empty='go': default, go name style, better performance in crud operation in
	// go (like: UserName) 'snake': snake name style (like: user_name)
	NameStyle string `protobuf:"bytes,1,opt,name=NameStyle,proto3" json:"NameStyle,omitempty"`
	// contains filtered or unexported fields
}

func (*PDBFile) Descriptor deprecated

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

Deprecated: Use PDBFile.ProtoReflect.Descriptor instead.

func (*PDBFile) GetNameStyle

func (x *PDBFile) GetNameStyle() string

func (*PDBFile) ProtoMessage

func (*PDBFile) ProtoMessage()

func (*PDBFile) ProtoReflect

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

func (*PDBFile) Reset

func (x *PDBFile) Reset()

func (*PDBFile) String

func (x *PDBFile) String() string

type PDBMsg

type PDBMsg struct {

	// when table primary key include more than one field,need specify the primary
	// key in pdbmsg
	Primary []string `protobuf:"bytes,1,rep,name=Primary,proto3" json:"Primary,omitempty"`
	// sql prepends before create table
	SQLPrepend []string `protobuf:"bytes,2,rep,name=SQLPrepend,proto3" json:"SQLPrepend,omitempty"`
	// sql appends before )
	SQLAppend []string `protobuf:"bytes,3,rep,name=SQLAppend,proto3" json:"SQLAppend,omitempty"`
	// sql appends after ) before ;
	SQLAppendsAfter []string `protobuf:"bytes,4,rep,name=SQLAppendsAfter,proto3" json:"SQLAppendsAfter,omitempty"`
	// sql appends after ;
	SQLAppendsEnd []string `protobuf:"bytes,5,rep,name=SQLAppendsEnd,proto3" json:"SQLAppendsEnd,omitempty"`
	// generate proto msg { {msg}}List in  xxx.list.proto
	// 0: auto if msg name start with db then generate { {msg}}List
	// 1: always generate { {msg}}List
	// 4: never generate { {msg}}List
	MsgList int32 `protobuf:"varint,6,opt,name=MsgList,proto3" json:"MsgList,omitempty"`
	// contains filtered or unexported fields
}

func (*PDBMsg) Descriptor deprecated

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

Deprecated: Use PDBMsg.ProtoReflect.Descriptor instead.

func (*PDBMsg) GetMsgList added in v0.1.1

func (x *PDBMsg) GetMsgList() int32

func (*PDBMsg) GetPrimary added in v0.1.3

func (x *PDBMsg) GetPrimary() []string

func (*PDBMsg) GetSQLAppend added in v0.1.3

func (x *PDBMsg) GetSQLAppend() []string

func (*PDBMsg) GetSQLAppendsAfter

func (x *PDBMsg) GetSQLAppendsAfter() []string

func (*PDBMsg) GetSQLAppendsEnd

func (x *PDBMsg) GetSQLAppendsEnd() []string

func (*PDBMsg) GetSQLPrepend added in v0.1.3

func (x *PDBMsg) GetSQLPrepend() []string

func (*PDBMsg) ProtoMessage

func (*PDBMsg) ProtoMessage()

func (*PDBMsg) ProtoReflect

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

func (*PDBMsg) Reset

func (x *PDBMsg) Reset()

func (*PDBMsg) String

func (x *PDBMsg) String() string

Jump to

Keyboard shortcuts

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