interface.go 3.6 KB

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