orm

package
v0.0.0-...-fc59d6d Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IndexOpKind_name = map[int32]string{
		0: "USE",
		1: "FORCE",
		2: "IGNORE",
	}
	IndexOpKind_value = map[string]int32{
		"USE":    0,
		"FORCE":  1,
		"IGNORE": 2,
	}
)

Enum value maps for IndexOpKind.

View Source
var (
	IndexForKind_name = map[int32]string{
		0: "FOR_OBJ_NIL",
		1: "JOIN",
		2: "GROUP_BY",
		3: "ORDER_BY",
	}
	IndexForKind_value = map[string]int32{
		"FOR_OBJ_NIL": 0,
		"JOIN":        1,
		"GROUP_BY":    2,
		"ORDER_BY":    3,
	}
)

Enum value maps for IndexForKind.

View Source
var (
	TimestampKind_name = map[int32]string{
		0: "UNSPECIFIED",
		1: "SECOND",
		2: "MILLI",
		3: "NANO",
	}
	TimestampKind_value = map[string]int32{
		"UNSPECIFIED": 0,
		"SECOND":      1,
		"MILLI":       2,
		"NANO":        3,
	}
)

Enum value maps for TimestampKind.

View Source
var (
	// option (orm.enable) = true;
	//
	// optional bool enable = 1171;
	E_Enable = &file_orm_orm_proto_extTypes[0]
	// option (orm.table_name) = "my_table_name";
	//
	// optional string table_name = 1172;
	E_TableName = &file_orm_orm_proto_extTypes[1]
	// repeated orm.IndexClause index_clauses = 1173;
	E_IndexClauses = &file_orm_orm_proto_extTypes[2]
)

Extension fields to descriptorpb.MessageOptions.

View Source
var (
	// optional orm.ORMTags tags = 1171;
	E_Tags = &file_orm_orm_proto_extTypes[3]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var File_orm_orm_proto protoreflect.FileDescriptor

Functions

func JoinStringsByCamel

func JoinStringsByCamel(ss []string) string

func SnakeToCamel

func SnakeToCamel(s string) string

Types

type IndexClause

type IndexClause struct {
	Op     IndexOpKind  `protobuf:"varint,1,opt,name=op,proto3,enum=orm.IndexOpKind" json:"op,omitempty"`
	For    IndexForKind `protobuf:"varint,2,opt,name=for,proto3,enum=orm.IndexForKind" json:"for,omitempty"`
	Indexs []string     `protobuf:"bytes,3,rep,name=indexs,proto3" json:"indexs,omitempty"`
	// contains filtered or unexported fields
}

func (*IndexClause) Descriptor deprecated

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

Deprecated: Use IndexClause.ProtoReflect.Descriptor instead.

func (*IndexClause) GetFor

func (x *IndexClause) GetFor() IndexForKind

func (*IndexClause) GetIndexs

func (x *IndexClause) GetIndexs() []string

func (*IndexClause) GetOp

func (x *IndexClause) GetOp() IndexOpKind

func (*IndexClause) ProtoMessage

func (*IndexClause) ProtoMessage()

func (*IndexClause) ProtoReflect

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

func (*IndexClause) Reset

func (x *IndexClause) Reset()

func (*IndexClause) String

func (x *IndexClause) String() string

func (*IndexClause) ToFuncName

func (x *IndexClause) ToFuncName() (string, error)

func (*IndexClause) ToString

func (x *IndexClause) ToString() string

type IndexForKind

type IndexForKind int32
const (
	IndexForKind_FOR_OBJ_NIL IndexForKind = 0
	IndexForKind_JOIN        IndexForKind = 1
	IndexForKind_GROUP_BY    IndexForKind = 2
	IndexForKind_ORDER_BY    IndexForKind = 3
)

func (IndexForKind) Descriptor

func (IndexForKind) Enum

func (x IndexForKind) Enum() *IndexForKind

func (IndexForKind) EnumDescriptor deprecated

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

Deprecated: Use IndexForKind.Descriptor instead.

func (IndexForKind) Number

func (IndexForKind) String

func (x IndexForKind) String() string

func (IndexForKind) Type

type IndexOpKind

type IndexOpKind int32
const (
	IndexOpKind_USE    IndexOpKind = 0
	IndexOpKind_FORCE  IndexOpKind = 1
	IndexOpKind_IGNORE IndexOpKind = 2
)

func (IndexOpKind) Descriptor

func (IndexOpKind) Enum

func (x IndexOpKind) Enum() *IndexOpKind

func (IndexOpKind) EnumDescriptor deprecated

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

Deprecated: Use IndexOpKind.Descriptor instead.

func (IndexOpKind) Number

func (x IndexOpKind) Number() protoreflect.EnumNumber

func (IndexOpKind) String

func (x IndexOpKind) String() string

func (IndexOpKind) Type

type ORMTags

type ORMTags struct {

	// 指定 db 列名
	Column *string `protobuf:"bytes,1,opt,name=column,proto3,oneof" json:"column,omitempty"`
	// 列数据类型,推荐使用兼容性好的通用类型,
	// 例如:所有数据库都支持 bool、int、uint、float、string、time、bytes
	// 并且可以和其他标签一起使用,例如:not null、size, autoIncrement…
	// 像 varbinary(8) 这样指定数据库数据类型也是支持的。
	// 在使用指定数据库数据类型时,它需要是完整的数据库数据类型,
	// 如:MEDIUMINT UNSIGNED not NULL AUTO_INCREMENT
	Type *string `protobuf:"bytes,2,opt,name=type,proto3,oneof" json:"type,omitempty"`
	// 定义列的默认值
	Default *string `protobuf:"bytes,3,opt,name=default,proto3,oneof" json:"default,omitempty"`
	// 指定列为 NOT NULL
	NotNull *bool `protobuf:"varint,4,opt,name=not_null,json=notNull,proto3,oneof" json:"not_null,omitempty"`
	// 迁移时为字段添加注释
	Comment *string `protobuf:"bytes,5,opt,name=comment,proto3,oneof" json:"comment,omitempty"`
	// 将列定义为主键
	PrimaryKey *bool `protobuf:"varint,6,opt,name=primary_key,json=primaryKey,proto3,oneof" json:"primary_key,omitempty"`
	// 根据参数创建索引,多个字段使用相同的名称则创建复合索引
	//
	//	type User struct {
	//	   Name  string `gorm:"index"`
	//	   Name2 string `gorm:"index:idx_name,unique"`
	//	   Name3 string `gorm:"index:,sort:desc,collate:utf8,type:btree,length:10,where:name3 != 'jinzhu'"`
	//	   Name4 string `gorm:"uniqueIndex"`
	//	   Age   int64  `gorm:"index:,class:FULLTEXT,comment:hello \\, world,where:age > 10"`
	//	   Age2  int64  `gorm:"index:,expression:ABS(age)"`
	//	}
	//
	// 您可以使用 priority 指定顺序,默认优先级值是 10,如果优先级值相同,则顺序取决于模型结构体字段的顺序。
	//
	//	type User struct {
	//	   Name   string `gorm:"index:idx_member,priority:2"`
	//	   Number string `gorm:"index:idx_member,priority:1"`
	//	}
	//
	// 多索引
	//
	//	type User struct {
	//	   Name   string `gorm:"index:idx_member;uniqueIndex:idx_member2"`
	//	   Number string `gorm:"index:idx_member;index:idx_member2,unique"`
	//	}
	//
	// // MySQL 选项
	//
	//	type User struct {
	//	    Name string `gorm:"index:,class:FULLTEXT,option:WITH PARSER ngram INVISIBLE"`
	//	}
	//
	// // PostgreSQL 选项
	//
	//	type User struct {
	//	    Name string `gorm:"index:,option:CONCURRENTLY"`
	//	}
	Indexs []string `protobuf:"bytes,8,rep,name=indexs,proto3" json:"indexs,omitempty"`
	// uniqueIndex 标签的作用与 index 类似,它等效于 index:,unique
	//
	//	type User struct {
	//	   Name  string `gorm:"uniqueIndex"`
	//	   Name2 string `gorm:"uniqueIndex:idx_name"`
	//	}
	UniqueIndexs []string `protobuf:"bytes,9,rep,name=unique_indexs,json=uniqueIndexs,proto3" json:"unique_indexs,omitempty"`
	// 定义列数据类型的大小或长度,例如 size: 256
	Size *int64 `protobuf:"varint,10,opt,name=size,proto3,oneof" json:"size,omitempty"`
	// 指定列的精度
	Precision *int64 `protobuf:"varint,11,opt,name=precision,proto3,oneof" json:"precision,omitempty"`
	// 指定列大小
	Scale *int64 `protobuf:"varint,12,opt,name=scale,proto3,oneof" json:"scale,omitempty"`
	// 嵌套字段
	Embedded *bool `protobuf:"varint,13,opt,name=embedded,proto3,oneof" json:"embedded,omitempty"`
	// 嵌入字段的列名前缀
	EmbeddedPrefix *string `protobuf:"bytes,14,opt,name=embedded_prefix,json=embeddedPrefix,proto3,oneof" json:"embedded_prefix,omitempty"`
	// 指定列为自动增长
	AutoIncrement *bool `protobuf:"varint,15,opt,name=auto_increment,json=autoIncrement,proto3,oneof" json:"auto_increment,omitempty"`
	// 指定自动增长的步长,控制连续记录之间的间隔
	AutoIncrementIncrement *int64 `` /* 137-byte string literal not displayed */
	// 创建时追踪当前时间,对于 int 字段,它会追踪时间戳秒数,
	// 您可以使用 nano/milli 来追踪纳秒、毫秒时间戳,
	// 例如:autoCreateTime:nano
	AutoCreateTime *TimestampKind `` /* 136-byte string literal not displayed */
	// 创建/更新时追踪当前时间,对于 int 字段,它会追踪时间戳秒数,
	// 您可以使用 nano/milli 来追踪纳秒、毫秒时间戳,
	// 例如:autoUpdateTime:milli
	AutoUpdateTime *TimestampKind `` /* 136-byte string literal not displayed */
	// 创建检查约束,例如 check:age > 13,或者 check:age > 13 and age < 18
	// 请注意,如果您使用的是 MySQL 5.7 或更低版本,则不支持检查约束。
	//
	//	type UserIndex struct {
	//	   Name  string `gorm:"check:name_checker,name <> 'jinzhu'"`
	//	   Name2 string `gorm:"check:name <> 'jinzhu'"`
	//	   Name3 string `gorm:"check:,name <> 'jinzhu'"`
	//	}
	Check *string `protobuf:"bytes,19,opt,name=check,proto3,oneof" json:"check,omitempty"`
	// constraint 标签的 OnDelete、OnUpdate 选项设置外键约束,例如:
	// `gorm:"constraint:OnDelete:CASCADE;OnUpdate:SET NULL;"`
	Constraint *string `protobuf:"bytes,20,opt,name=constraint,proto3,oneof" json:"constraint,omitempty"`
	// 忽略该字段
	// - 表示无读写
	IgnoreRw *bool `protobuf:"varint,21,opt,name=ignore_rw,json=ignoreRw,proto3,oneof" json:"ignore_rw,omitempty"`
	// -:migration 表示无迁移权限,
	IgnoreMigration *bool `protobuf:"varint,22,opt,name=ignore_migration,json=ignoreMigration,proto3,oneof" json:"ignore_migration,omitempty"`
	// -:all 表示无读写迁移权限
	IgnoreAll *bool `protobuf:"varint,23,opt,name=ignore_all,json=ignoreAll,proto3,oneof" json:"ignore_all,omitempty"`
	// 设置字段写入的权限, <-:create 只创建
	OnlyCreate *bool `protobuf:"varint,24,opt,name=only_create,json=onlyCreate,proto3,oneof" json:"only_create,omitempty"`
	// 设置字段写入的权限, <-:update 只更新
	OnlyUpdate *bool `protobuf:"varint,25,opt,name=only_update,json=onlyUpdate,proto3,oneof" json:"only_update,omitempty"`
	// <-:false 无写入权限
	DisableWrite *bool `protobuf:"varint,26,opt,name=disable_write,json=disableWrite,proto3,oneof" json:"disable_write,omitempty"`
	// ->:false 无读取权限
	DisableRead *bool `protobuf:"varint,27,opt,name=disable_read,json=disableRead,proto3,oneof" json:"disable_read,omitempty"`
	// 指定将数据序列化或反序列化到数据库中的序列化器,
	// 例如: serializer:json/gob/unixtime
	Serializer *string `protobuf:"bytes,28,opt,name=serializer,proto3,oneof" json:"serializer,omitempty"`
	// contains filtered or unexported fields
}

func (*ORMTags) Descriptor deprecated

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

Deprecated: Use ORMTags.ProtoReflect.Descriptor instead.

func (*ORMTags) GetAutoCreateTime

func (x *ORMTags) GetAutoCreateTime() TimestampKind

func (*ORMTags) GetAutoIncrement

func (x *ORMTags) GetAutoIncrement() bool

func (*ORMTags) GetAutoIncrementIncrement

func (x *ORMTags) GetAutoIncrementIncrement() int64

func (*ORMTags) GetAutoUpdateTime

func (x *ORMTags) GetAutoUpdateTime() TimestampKind

func (*ORMTags) GetCheck

func (x *ORMTags) GetCheck() string

func (*ORMTags) GetColumn

func (x *ORMTags) GetColumn() string

func (*ORMTags) GetComment

func (x *ORMTags) GetComment() string

func (*ORMTags) GetConstraint

func (x *ORMTags) GetConstraint() string

func (*ORMTags) GetDefault

func (x *ORMTags) GetDefault() string

func (*ORMTags) GetDisableRead

func (x *ORMTags) GetDisableRead() bool

func (*ORMTags) GetDisableWrite

func (x *ORMTags) GetDisableWrite() bool

func (*ORMTags) GetEmbedded

func (x *ORMTags) GetEmbedded() bool

func (*ORMTags) GetEmbeddedPrefix

func (x *ORMTags) GetEmbeddedPrefix() string

func (*ORMTags) GetIgnoreAll

func (x *ORMTags) GetIgnoreAll() bool

func (*ORMTags) GetIgnoreMigration

func (x *ORMTags) GetIgnoreMigration() bool

func (*ORMTags) GetIgnoreRw

func (x *ORMTags) GetIgnoreRw() bool

func (*ORMTags) GetIndexs

func (x *ORMTags) GetIndexs() []string

func (*ORMTags) GetNotNull

func (x *ORMTags) GetNotNull() bool

func (*ORMTags) GetOnlyCreate

func (x *ORMTags) GetOnlyCreate() bool

func (*ORMTags) GetOnlyUpdate

func (x *ORMTags) GetOnlyUpdate() bool

func (*ORMTags) GetPrecision

func (x *ORMTags) GetPrecision() int64

func (*ORMTags) GetPrimaryKey

func (x *ORMTags) GetPrimaryKey() bool

func (*ORMTags) GetScale

func (x *ORMTags) GetScale() int64

func (*ORMTags) GetSerializer

func (x *ORMTags) GetSerializer() string

func (*ORMTags) GetSize

func (x *ORMTags) GetSize() int64

func (*ORMTags) GetType

func (x *ORMTags) GetType() string

func (*ORMTags) GetUniqueIndexs

func (x *ORMTags) GetUniqueIndexs() []string

func (*ORMTags) ProtoMessage

func (*ORMTags) ProtoMessage()

func (*ORMTags) ProtoReflect

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

func (*ORMTags) Reset

func (x *ORMTags) Reset()

func (*ORMTags) String

func (x *ORMTags) String() string

type TimestampKind

type TimestampKind int32
const (
	TimestampKind_UNSPECIFIED TimestampKind = 0
	TimestampKind_SECOND      TimestampKind = 1
	TimestampKind_MILLI       TimestampKind = 2
	TimestampKind_NANO        TimestampKind = 3
)

func (TimestampKind) Descriptor

func (TimestampKind) Enum

func (x TimestampKind) Enum() *TimestampKind

func (TimestampKind) EnumDescriptor deprecated

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

Deprecated: Use TimestampKind.Descriptor instead.

func (TimestampKind) Number

func (TimestampKind) String

func (x TimestampKind) String() string

func (TimestampKind) Type

Jump to

Keyboard shortcuts

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