interface.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. "github.com/xormplus/core"
  11. )
  12. // Interface defines the interface which Engine, EngineGroup and Session will implementate.
  13. type Interface interface {
  14. AllCols() *Session
  15. Alias(alias string) *Session
  16. Asc(colNames ...string) *Session
  17. BufferSize(size int) *Session
  18. Cols(columns ...string) *Session
  19. Count(...interface{}) (int64, error)
  20. CreateIndexes(bean interface{}) error
  21. CreateUniques(bean interface{}) error
  22. Decr(column string, arg ...interface{}) *Session
  23. Desc(...string) *Session
  24. Delete(interface{}) (int64, error)
  25. Distinct(columns ...string) *Session
  26. DropIndexes(bean interface{}) error
  27. Exec(sqlOrAgrs ...interface{}) (sql.Result, error)
  28. Exist(bean ...interface{}) (bool, error)
  29. Find(interface{}, ...interface{}) error
  30. FindAndCount(interface{}, ...interface{}) (int64, error)
  31. Get(interface{}) (bool, error)
  32. GroupBy(keys string) *Session
  33. ID(interface{}) *Session
  34. In(string, ...interface{}) *Session
  35. Incr(column string, arg ...interface{}) *Session
  36. Insert(...interface{}) (int64, error)
  37. InsertOne(interface{}) (int64, error)
  38. IsTableEmpty(bean interface{}) (bool, error)
  39. IsTableExist(beanOrTableName interface{}) (bool, error)
  40. Iterate(interface{}, IterFunc) error
  41. Limit(int, ...int) *Session
  42. MustCols(columns ...string) *Session
  43. NoAutoCondition(...bool) *Session
  44. NotIn(string, ...interface{}) *Session
  45. Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
  46. Omit(columns ...string) *Session
  47. OrderBy(order string) *Session
  48. Ping() error
  49. QueryBytes(sqlOrAgrs ...interface{}) (resultsSlice []map[string][]byte, err error)
  50. QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error)
  51. QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error)
  52. QueryValue(sqlOrArgs ...interface{}) ([]map[string]Value, error)
  53. QueryResult(sqlOrArgs ...interface{}) (result *ResultValue)
  54. Rows(bean interface{}) (*Rows, error)
  55. SetExpr(string, string) *Session
  56. SQL(interface{}, ...interface{}) *Session
  57. Sum(bean interface{}, colName string) (float64, error)
  58. SumInt(bean interface{}, colName string) (int64, error)
  59. Sums(bean interface{}, colNames ...string) ([]float64, error)
  60. SumsInt(bean interface{}, colNames ...string) ([]int64, error)
  61. Table(tableNameOrBean interface{}) *Session
  62. Unscoped() *Session
  63. Update(bean interface{}, condiBeans ...interface{}) (int64, error)
  64. UseBool(...string) *Session
  65. Where(interface{}, ...interface{}) *Session
  66. }
  67. // EngineInterface defines the interface which Engine, EngineGroup will implementate.
  68. type EngineInterface interface {
  69. Interface
  70. Before(func(interface{})) *Session
  71. Charset(charset string) *Session
  72. ClearCache(...interface{}) error
  73. Context(context.Context) *Session
  74. CreateTables(...interface{}) error
  75. DBMetas() ([]*core.Table, error)
  76. Dialect() core.Dialect
  77. DropTables(...interface{}) error
  78. DumpAllToFile(fp string, tp ...core.DbType) error
  79. GetCacher(string) core.Cacher
  80. GetColumnMapper() core.IMapper
  81. GetDefaultCacher() core.Cacher
  82. GetTableMapper() core.IMapper
  83. GetTZDatabase() *time.Location
  84. GetTZLocation() *time.Location
  85. MapCacher(interface{}, core.Cacher) error
  86. NewSession() *Session
  87. NoAutoTime() *Session
  88. Quote(string) string
  89. SetCacher(string, core.Cacher)
  90. SetConnMaxLifetime(time.Duration)
  91. SetDefaultCacher(core.Cacher)
  92. SetLogger(logger core.ILogger)
  93. SetLogLevel(core.LogLevel)
  94. SetMapper(core.IMapper)
  95. SetMaxOpenConns(int)
  96. SetMaxIdleConns(int)
  97. SetSchema(string)
  98. SetTZDatabase(tz *time.Location)
  99. SetTZLocation(tz *time.Location)
  100. ShowExecTime(...bool)
  101. ShowSQL(show ...bool)
  102. Sync(...interface{}) error
  103. Sync2(...interface{}) error
  104. StoreEngine(storeEngine string) *Session
  105. TableInfo(bean interface{}) *Table
  106. TableName(interface{}, ...bool) string
  107. UnMapType(reflect.Type)
  108. }
  109. var (
  110. _ Interface = &Session{}
  111. _ EngineInterface = &Engine{}
  112. _ EngineInterface = &EngineGroup{}
  113. )