protodb

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 6 Imported by: 1

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",
		13: "UINT32",
	}
	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,
		"UINT32":    13,
	}
)

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

func GetProtoDBType added in v0.1.5

func GetProtoDBType(fieldType protoreflect.Kind) string

Types

type DMLResult added in v0.1.5

type DMLResult struct {

	// RowsAffected in dml operation
	RowsAffected int64 `protobuf:"varint,1,opt,name=RowsAffected,proto3" json:"RowsAffected,omitempty"`
	// err info when error happened
	ErrInfo string `protobuf:"bytes,2,opt,name=ErrInfo,proto3" json:"ErrInfo,omitempty"`
	// contains filtered or unexported fields
}

CRUD DML Result

func (*DMLResult) Descriptor deprecated added in v0.1.5

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

Deprecated: Use DMLResult.ProtoReflect.Descriptor instead.

func (*DMLResult) GetErrInfo added in v0.1.5

func (x *DMLResult) GetErrInfo() string

func (*DMLResult) GetRowsAffected added in v0.1.5

func (x *DMLResult) GetRowsAffected() int64

func (*DMLResult) ProtoMessage added in v0.1.5

func (*DMLResult) ProtoMessage()

func (*DMLResult) ProtoReflect added in v0.1.5

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

func (*DMLResult) Reset added in v0.1.5

func (x *DMLResult) Reset()

func (*DMLResult) String added in v0.1.5

func (x *DMLResult) String() string

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
	FieldDbType_UINT32 FieldDbType = 13
)

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, if the unique include multiple columns, specify the UniqueName
	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 2:smallint(serial2) 4:integer(serial4) 8:bigint(serial8)
	// 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"`
	// db no insert
	// when in insert, do not insert this field, for example, database has default value
	NoInsert bool `protobuf:"varint,14,opt,name=NoInsert,proto3" json:"NoInsert,omitempty"`
	// comment for field
	Comment []string `protobuf:"bytes,15,rep,name=Comment,proto3" json:"Comment,omitempty"`
	// unique group name
	// when a unique constrain include multiple column, specify the a group name for it
	UniqueName string `protobuf:"bytes,16,opt,name=UniqueName,proto3" json:"UniqueName,omitempty"`
	// contains filtered or unexported fields
}

func (*PDBField) Descriptor deprecated

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

Deprecated: Use PDBField.ProtoReflect.Descriptor instead.

func (*PDBField) GetComment added in v0.1.5

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

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) GetNoInsert added in v0.1.5

func (x *PDBField) GetNoInsert() bool

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) GetUniqueName added in v0.1.5

func (x *PDBField) GetUniqueName() string

func (*PDBField) GetZeroAsNull added in v0.1.3

func (x *PDBField) GetZeroAsNull() bool

func (*PDBField) IsAutoIncrement added in v0.1.5

func (x *PDBField) IsAutoIncrement() bool

is auto increment

func (*PDBField) IsNoUpdate added in v0.1.5

func (x *PDBField) IsNoUpdate() bool

is no update

func (*PDBField) IsNotDB added in v0.1.5

func (x *PDBField) IsNotDB() bool

not in db

func (*PDBField) IsNotNull

func (x *PDBField) IsNotNull() bool

is not null

func (*PDBField) IsPrimary added in v0.1.2

func (x *PDBField) IsPrimary() bool

is primary key

func (*PDBField) IsReference added in v0.1.5

func (x *PDBField) IsReference() bool

is reference

func (*PDBField) IsSerial added in v0.1.5

func (x *PDBField) IsSerial() bool

is serial type == isautoincrement

func (*PDBField) IsUnique added in v0.1.2

func (x *PDBField) IsUnique() bool

is unique

func (*PDBField) IsZeroAsNull added in v0.1.5

func (x *PDBField) IsZeroAsNull() bool

zero as null

func (*PDBField) NeedInInsert added in v0.1.5

func (x *PDBField) NeedInInsert() bool

need in insert

func (*PDBField) NeedInUpdate added in v0.1.5

func (x *PDBField) NeedInUpdate() bool

need in update

func (*PDBField) PdbDbTypeStr added in v0.1.5

func (x *PDBField) PdbDbTypeStr(fieldMsg protoreflect.FieldDescriptor) string

PdbDbTypeStr get db type string from pdb if specified

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"`
	// comment for file
	Comment []string `protobuf:"bytes,2,rep,name=Comment,proto3" json:"Comment,omitempty"`
	// contains filtered or unexported fields
}

func (*PDBFile) Descriptor deprecated

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

Deprecated: Use PDBFile.ProtoReflect.Descriptor instead.

func (*PDBFile) GetComment added in v0.1.5

func (x *PDBFile) GetComment() []string

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 {

	// comment for table
	Comment []string `protobuf:"bytes,1,rep,name=Comment,proto3" json:"Comment,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) GetComment added in v0.1.5

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

func (*PDBMsg) GetMsgList added in v0.1.1

func (x *PDBMsg) GetMsgList() int32

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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