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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
  51. Omit(columns ...string) *Session
  52. OrderBy(order string) *Session
  53. Ping() error
  54. Query(sqlOrArgs ...interface{}) (resultsSlice []map[string][]byte, err error)
  55. QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error)
  56. QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error)
  57. Rows(bean interface{}) (*Rows, error)
  58. SetExpr(string, interface{}) *Session
  59. Select(string) *Session
  60. SQL(interface{}, ...interface{}) *Session
  61. Sum(bean interface{}, colName string) (float64, error)
  62. SumInt(bean interface{}, colName string) (int64, error)
  63. Sums(bean interface{}, colNames ...string) ([]float64, error)
  64. SumsInt(bean interface{}, colNames ...string) ([]int64, error)
  65. Table(tableNameOrBean interface{}) *Session
  66. Unscoped() *Session
  67. Update(bean interface{}, condiBeans ...interface{}) (int64, error)
  68. UseBool(...string) *Session
  69. Where(interface{}, ...interface{}) *Session
  70. }
  71. // EngineInterface defines the interface which Engine, EngineGroup will implementate.
  72. type EngineInterface interface {
  73. Interface
  74. Before(func(interface{})) *Session
  75. Charset(charset string) *Session
  76. ClearCache(...interface{}) error
  77. Context(context.Context) *Session
  78. CreateTables(...interface{}) error
  79. DBMetas() ([]*schemas.Table, error)
  80. Dialect() dialects.Dialect
  81. DriverName() string
  82. DropTables(...interface{}) error
  83. DumpAllToFile(fp string, tp ...schemas.DBType) error
  84. GetCacher(string) caches.Cacher
  85. GetColumnMapper() names.Mapper
  86. GetDefaultCacher() caches.Cacher
  87. GetTableMapper() names.Mapper
  88. GetTZDatabase() *time.Location
  89. GetTZLocation() *time.Location
  90. ImportFile(fp string) ([]sql.Result, error)
  91. MapCacher(interface{}, caches.Cacher) error
  92. NewSession() *Session
  93. NoAutoTime() *Session
  94. Quote(string) string
  95. SetCacher(string, caches.Cacher)
  96. SetConnMaxLifetime(time.Duration)
  97. SetColumnMapper(names.Mapper)
  98. SetDefaultCacher(caches.Cacher)
  99. SetLogger(logger interface{})
  100. SetLogLevel(log.LogLevel)
  101. SetMapper(names.Mapper)
  102. SetMaxOpenConns(int)
  103. SetMaxIdleConns(int)
  104. SetQuotePolicy(dialects.QuotePolicy)
  105. SetSchema(string)
  106. SetTableMapper(names.Mapper)
  107. SetTZDatabase(tz *time.Location)
  108. SetTZLocation(tz *time.Location)
  109. AddHook(hook contexts.Hook)
  110. ShowSQL(show ...bool)
  111. Sync(...interface{}) error
  112. Sync2(...interface{}) error
  113. StoreEngine(storeEngine string) *Session
  114. TableInfo(bean interface{}) (*schemas.Table, error)
  115. TableName(interface{}, ...bool) string
  116. UnMapType(reflect.Type)
  117. EnableSessionID(bool)
  118. }
  119. var (
  120. _ Interface = &Session{}
  121. _ EngineInterface = &Engine{}
  122. _ EngineInterface = &EngineGroup{}
  123. )