Documentation ¶
Index ¶
- Variables
- func JoinORMTags(tags *ORMTags) string
- func JoinStringsByCamel(ss []string) string
- func JoinTags(jsonName string, args ...string) string
- func SnakeToCamel(s string) string
- func TimeKindToString(kind TimestampKind) string
- type FileDesc
- type IndexClause
- func (*IndexClause) Descriptor() ([]byte, []int)deprecated
- func (x *IndexClause) GetFor() IndexForKind
- func (x *IndexClause) GetIndexs() []string
- func (x *IndexClause) GetOp() IndexOpKind
- func (*IndexClause) ProtoMessage()
- func (x *IndexClause) ProtoReflect() protoreflect.Message
- func (x *IndexClause) Reset()
- func (x *IndexClause) String() string
- func (x *IndexClause) ToFuncName() (string, error)
- func (x *IndexClause) ToString() string
- type IndexForKind
- func (IndexForKind) Descriptor() protoreflect.EnumDescriptor
- func (x IndexForKind) Enum() *IndexForKind
- func (IndexForKind) EnumDescriptor() ([]byte, []int)deprecated
- func (x IndexForKind) Number() protoreflect.EnumNumber
- func (x IndexForKind) String() string
- func (IndexForKind) Type() protoreflect.EnumType
- type IndexOpKind
- func (IndexOpKind) Descriptor() protoreflect.EnumDescriptor
- func (x IndexOpKind) Enum() *IndexOpKind
- func (IndexOpKind) EnumDescriptor() ([]byte, []int)deprecated
- func (x IndexOpKind) Number() protoreflect.EnumNumber
- func (x IndexOpKind) String() string
- func (IndexOpKind) Type() protoreflect.EnumType
- type MessageDesc
- type MessageOpts
- type ORMField
- type ORMTags
- func (*ORMTags) Descriptor() ([]byte, []int)deprecated
- func (x *ORMTags) GetAutoCreateTime() TimestampKind
- func (x *ORMTags) GetAutoIncrement() bool
- func (x *ORMTags) GetAutoIncrementIncrement() int64
- func (x *ORMTags) GetAutoUpdateTime() TimestampKind
- func (x *ORMTags) GetCheck() string
- func (x *ORMTags) GetColumn() string
- func (x *ORMTags) GetComment() string
- func (x *ORMTags) GetConstraint() string
- func (x *ORMTags) GetDefault() string
- func (x *ORMTags) GetDisableRead() bool
- func (x *ORMTags) GetDisableWrite() bool
- func (x *ORMTags) GetEmbedded() bool
- func (x *ORMTags) GetEmbeddedPrefix() string
- func (x *ORMTags) GetEncrypt() bool
- func (x *ORMTags) GetIgnoreAll() bool
- func (x *ORMTags) GetIgnoreMigration() bool
- func (x *ORMTags) GetIgnoreRw() bool
- func (x *ORMTags) GetIndex() []string
- func (x *ORMTags) GetNotNull() bool
- func (x *ORMTags) GetOnlyCreate() bool
- func (x *ORMTags) GetOnlyUpdate() bool
- func (x *ORMTags) GetPrecision() int64
- func (x *ORMTags) GetPrimaryKey() bool
- func (x *ORMTags) GetScale() int64
- func (x *ORMTags) GetSerializer() string
- func (x *ORMTags) GetSize() int64
- func (x *ORMTags) GetType() string
- func (x *ORMTags) GetUniqueIndex() []string
- func (*ORMTags) ProtoMessage()
- func (x *ORMTags) ProtoReflect() protoreflect.Message
- func (x *ORMTags) Reset()
- func (x *ORMTags) String() string
- type SerializeDesc
- type TimestampKind
- func (TimestampKind) Descriptor() protoreflect.EnumDescriptor
- func (x TimestampKind) Enum() *TimestampKind
- func (TimestampKind) EnumDescriptor() ([]byte, []int)deprecated
- func (x TimestampKind) Number() protoreflect.EnumNumber
- func (x TimestampKind) String() string
- func (TimestampKind) Type() protoreflect.EnumType
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 JoinORMTags ¶
func JoinStringsByCamel ¶
func SnakeToCamel ¶
func TimeKindToString ¶
func TimeKindToString(kind TimestampKind) string
Types ¶
type FileDesc ¶
type FileDesc struct { PackageName string Imports []string Commons []string Messages []*MessageDesc }
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) Descriptor() protoreflect.EnumDescriptor
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 (x IndexForKind) Number() protoreflect.EnumNumber
func (IndexForKind) String ¶
func (x IndexForKind) String() string
func (IndexForKind) Type ¶
func (IndexForKind) Type() protoreflect.EnumType
type IndexOpKind ¶
type IndexOpKind int32
const ( IndexOpKind_USE IndexOpKind = 0 IndexOpKind_FORCE IndexOpKind = 1 IndexOpKind_IGNORE IndexOpKind = 2 )
func (IndexOpKind) Descriptor ¶
func (IndexOpKind) Descriptor() protoreflect.EnumDescriptor
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 ¶
func (IndexOpKind) Type() protoreflect.EnumType
type MessageDesc ¶
type MessageDesc struct { Name string Opts *MessageOpts Fields []*ORMField SerializeFields []*SerializeDesc UtilMap map[string]string Imports []string }
type MessageOpts ¶
type MessageOpts struct { TableName string IndexClauses []*IndexClause }
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"` // } Index []string `protobuf:"bytes,8,rep,name=index,proto3" json:"index,omitempty"` // uniqueIndex 标签的作用与 index 类似,它等效于 index:,unique // // type User struct { // Name string `gorm:"uniqueIndex"` // Name2 string `gorm:"uniqueIndex:idx_name"` // } UniqueIndex []string `protobuf:"bytes,9,rep,name=unique_index,json=uniqueIndex,proto3" json:"unique_index,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"` Encrypt *bool `protobuf:"varint,29,opt,name=encrypt,proto3,oneof" json:"encrypt,omitempty"` // contains filtered or unexported fields }
func (*ORMTags) Descriptor
deprecated
func (*ORMTags) GetAutoCreateTime ¶
func (x *ORMTags) GetAutoCreateTime() TimestampKind
func (*ORMTags) GetAutoIncrement ¶
func (*ORMTags) GetAutoIncrementIncrement ¶
func (*ORMTags) GetAutoUpdateTime ¶
func (x *ORMTags) GetAutoUpdateTime() TimestampKind
func (*ORMTags) GetComment ¶
func (*ORMTags) GetConstraint ¶
func (*ORMTags) GetDefault ¶
func (*ORMTags) GetDisableRead ¶
func (*ORMTags) GetDisableWrite ¶
func (*ORMTags) GetEmbedded ¶
func (*ORMTags) GetEmbeddedPrefix ¶
func (*ORMTags) GetEncrypt ¶
func (*ORMTags) GetIgnoreAll ¶
func (*ORMTags) GetIgnoreMigration ¶
func (*ORMTags) GetIgnoreRw ¶
func (*ORMTags) GetNotNull ¶
func (*ORMTags) GetOnlyCreate ¶
func (*ORMTags) GetOnlyUpdate ¶
func (*ORMTags) GetPrecision ¶
func (*ORMTags) GetPrimaryKey ¶
func (*ORMTags) GetSerializer ¶
func (*ORMTags) GetUniqueIndex ¶
func (*ORMTags) ProtoMessage ¶
func (*ORMTags) ProtoMessage()
func (*ORMTags) ProtoReflect ¶
func (x *ORMTags) ProtoReflect() protoreflect.Message
type SerializeDesc ¶
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) Descriptor() protoreflect.EnumDescriptor
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 (x TimestampKind) Number() protoreflect.EnumNumber
func (TimestampKind) String ¶
func (x TimestampKind) String() string
func (TimestampKind) Type ¶
func (TimestampKind) Type() protoreflect.EnumType
Click to show internal directories.
Click to hide internal directories.