You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interface.go 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import (
  6. "context"
  7. "database/sql"
  8. "reflect"
  9. "time"
  10. "xorm.io/xorm/caches"
  11. "xorm.io/xorm/contexts"
  12. "xorm.io/xorm/dialects"
  13. "xorm.io/xorm/log"
  14. "xorm.io/xorm/names"
  15. "xorm.io/xorm/schemas"
  16. )
  17. // Interface defines the interface which Engine, EngineGroup and Session will implementate.
  18. type Interface interface {
  19. AllCols() *Session
  20. Alias(alias string) *Session
  21. Asc(colNames ...string) *Session
  22. BufferSize(size int) *Session
  23. Cols(columns ...string) *Session
  24. Count(...interface{}) (int64, error)
  25. CreateIndexes(bean interface{}) error
  26. CreateUniques(bean interface{}) error
  27. Decr(column string, arg ...interface{}) *Session
  28. Desc(...string) *Session
  29. Delete(...interface{}) (int64, error)
  30. Distinct(columns ...string) *Session
  31. DropIndexes(bean interface{}) error
  32. Exec(sqlOrArgs ...interface{}) (sql.Result, error)
  33. Exist(bean ...interface{}) (bool, error)
  34. Find(interface{}, ...interface{}) error
  35. FindAndCount(interface{}, ...interface{}) (int64, error)
  36. Get(interface{}) (bool, error)
  37. GroupBy(keys string) *Session
  38. ID(interface{}) *Session
  39. In(string, ...interface{}) *Session
  40. Incr(column string, arg ...interface{}) *Session
  41. Insert(...interface{}) (int64, error)
  42. InsertOne(interface{}) (int64, error)
  43. IsTableEmpty(bean interface{}) (bool, error)
  44. IsTableExist(beanOrTableName interface{}) (bool, error)
  45. Iterate(interface{}, IterFunc) error
  46. Limit(int, ...int) *Session
  47. MustCols(columns ...string) *Session
  48. NoAutoCondition(...bool) *Session
  49. NotIn(string, ...interface{}) *Session
  50. Nullable(...string) *Session
  51. Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
  52. Omit(columns ...string) *Session
  53. OrderBy(order string) *Session
  54. Ping() error
  55. Query(sqlOrArgs ...interface{}) (resultsSlice []map[string][]byte, err error)
  56. QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error)
  57. QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error)
  58. Rows(bean interface{}) (*Rows, error)
  59. SetExpr(string, interface{}) *Session
  60. Select(string) *Session
  61. SQL(interface{}, ...interface{}) *Session
  62. Sum(bean interface{}, colName string) (float64, error)
  63. SumInt(bean interface{}, colName string) (int64, error)
  64. Sums(bean interface{}, colNames ...string) ([]float64, error)
  65. SumsInt(bean interface{}, colNames ...string) ([]int64, error)
  66. Table(tableNameOrBean interface{}) *Session
  67. Unscoped() *Session
  68. Update(bean interface{}, condiBeans ...interface{}) (int64, error)
  69. UseBool(...string) *Session
  70. Where(interface{}, ...interface{}) *Session
  71. }
  72. // EngineInterface defines the interface which Engine, EngineGroup will implementate.
  73. type EngineInterface interface {
  74. Interface
  75. Before(func(interface{})) *Session
  76. Charset(charset string) *Session
  77. ClearCache(...interface{}) error
  78. Context(context.Context) *Session
  79. CreateTables(...interface{}) error
  80. DBMetas() ([]*schemas.Table, error)
  81. DBVersion() (*schemas.Version, error)
  82. Dialect() dialects.Dialect
  83. DriverName() string
  84. DropTables(...interface{}) error
  85. DumpAllToFile(fp string, tp ...schemas.DBType) error
  86. GetCacher(string) caches.Cacher
  87. GetColumnMapper() names.Mapper
  88. GetDefaultCacher() caches.Cacher
  89. GetTableMapper() names.Mapper
  90. GetTZDatabase() *time.Location
  91. GetTZLocation() *time.Location
  92. ImportFile(fp string) ([]sql.Result, error)
  93. MapCacher(interface{}, caches.Cacher) error
  94. NewSession() *Session
  95. NoAutoTime() *Session
  96. Quote(string) string
  97. SetCacher(string, caches.Cacher)
  98. SetConnMaxLifetime(time.Duration)
  99. SetColumnMapper(names.Mapper)
  100. SetTagIdentifier(string)
  101. SetDefaultCacher(caches.Cacher)
  102. SetLogger(logger interface{})
  103. SetLogLevel(log.LogLevel)
  104. SetMapper(names.Mapper)
  105. SetMaxOpenConns(int)
  106. SetMaxIdleConns(int)
  107. SetQuotePolicy(dialects.QuotePolicy)
  108. SetSchema(string)
  109. SetTableMapper(names.Mapper)
  110. SetTZDatabase(tz *time.Location)
  111. SetTZLocation(tz *time.Location)
  112. AddHook(hook contexts.Hook)
  113. ShowSQL(show ...bool)
  114. Sync(...interface{}) error
  115. Sync2(...interface{}) error
  116. StoreEngine(storeEngine string) *Session
  117. TableInfo(bean interface{}) (*schemas.Table, error)
  118. TableName(interface{}, ...bool) string
  119. UnMapType(reflect.Type)
  120. EnableSessionID(bool)
  121. }
  122. var (
  123. _ Interface = &Session{}
  124. _ EngineInterface = &Engine{}
  125. _ EngineInterface = &EngineGroup{}
  126. )