Documentation
¶
Index ¶
- Constants
- Variables
- func Kind(dest interface{}) reflect.Type
- func ParseTagSetting(str string, sep string) map[string]string
- func ToArray(v interface{}) (r []interface{})
- func ToInt(i any) (r int64)
- func ToInt32(i any) int32
- func ToString(value interface{}) string
- func ValueOf(i interface{}) reflect.Value
- type Field
- func (field *Field) Get(value reflect.Value) reflect.Value
- func (field *Field) GetEmbeddedFields() (r []*Field)
- func (field *Field) GetName(ks ...string) string
- func (field *Field) GetTagName(k string) string
- func (field *Field) ReflectValueOf(value reflect.Value) reflect.Value
- func (field *Field) Set(value reflect.Value, v interface{}) error
- func (field *Field) SetBool(value reflect.Value, v interface{}) error
- func (field *Field) SetFloat(value reflect.Value, v interface{}) error
- func (field *Field) SetInt(value reflect.Value, v interface{}) error
- func (field *Field) SetString(value reflect.Value, v interface{}) error
- func (field *Field) SetUint(value reflect.Value, v interface{}) error
- type Index
- type IndexField
- type IndexPartialParse
- type Namer
- type NamingStrategy
- type Options
- type Replacer
- type Schema
- func (schema *Schema) GetValue(obj any, key string, keys ...any) (r any)
- func (schema *Schema) JSName(k string) (r string)
- func (schema *Schema) LookIndex(name string) *Index
- func (schema *Schema) LookUpField(name string) *Field
- func (schema *Schema) Make() reflect.Value
- func (schema *Schema) New() reflect.Value
- func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field
- func (schema *Schema) ParseIndexes() map[string]*Index
- func (schema *Schema) Range(cb func(*Field) bool)
- func (schema *Schema) SetValue(obj any, val any, key string, keys ...any) (err error)
- func (schema *Schema) String() string
- type Tabler
Constants ¶
View Source
const ( IndexTag = "index" IndexName = "NAME" IndexSort = "SORT" IndexUnique = "UNIQUE" IndexSparse = "SPARSE" IndexPartial = "PARTIAL" //部分索引 index:"PARTIAL:{\"invite\":{\"$gt\":0}}"` IndexPriority = "PRIORITY" )
https://www.mongodb.com/zh-cn/docs/manual/core/index-partial/#std-label-index-type-partial 部分索引 使用一条查询语句
Variables ¶
View Source
var ErrUnsupportedDataType = errors.New("unsupported data type")
ErrUnsupportedDataType unsupported data type
Functions ¶
Types ¶
type Field ¶
type Field struct { Name string Index []int JSName string DBName string Schema *Schema //所在的父对象 Embedded *Schema //嵌入子对象 FieldType reflect.Type StructField reflect.StructField IndirectFieldType reflect.Type }
func (*Field) GetEmbeddedFields ¶ added in v1.1.0
func (*Field) GetTagName ¶ added in v1.2.0
func (*Field) ReflectValueOf ¶
type Index ¶
type Index struct { Name string Unique bool //唯一 Sparse bool //稀疏索引 Partial []string Fields []*IndexField // contains filtered or unexported fields }
func (*Index) Build ¶
func (this *Index) Build(whereParser ...IndexPartialParse) (index *mongo.IndexModel, err error)
type IndexField ¶
type IndexField struct { Sort string // DESC, ASC Name string // index name DBName []string // a.b.c Unique bool //唯一 Sparse bool //稀疏索引 Partial string //{ rating: { $gt: 5 } } Priority int //排序字段之间的排序ASC }
func (*IndexField) GetDBName ¶
func (this *IndexField) GetDBName() string
type IndexPartialParse ¶ added in v1.2.0
type NamingStrategy ¶
type NamingStrategy struct { TablePrefix string SingularTable bool NameReplacer Replacer NoLowerCase bool }
NamingStrategy tables, columns naming strategy
func (NamingStrategy) ColumnName ¶
func (ns NamingStrategy) ColumnName(table, column string) string
ColumnName convert string to column name
func (NamingStrategy) TableName ¶
func (ns NamingStrategy) TableName(str string) string
TableName convert string to table name
type Schema ¶
type Schema struct { Name string Table string Embedded []*Field //嵌入字段 ModelType reflect.Type Fields map[string]*Field // contains filtered or unexported fields }
func GetOrParse ¶ added in v1.1.0
func ParseWithSpecialTableName ¶
func ParseWithSpecialTableName(dest interface{}, specialTableName string, opts *Options) (*Schema, error)
ParseWithSpecialTableName get data type from dialector with extra schema table
func (*Schema) LookUpField ¶
func (*Schema) ParseField ¶
func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field
func (*Schema) ParseIndexes ¶
ParseIndexes parse schema indexes
Click to show internal directories.
Click to hide internal directories.