interface.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. NoAutoCondition(...bool) *Session
  42. NotIn(string, ...interface{}) *Session
  43. Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
  44. Omit(columns ...string) *Session
  45. OrderBy(order string) *Session
  46. Ping() error
  47. Query(sqlOrAgrs ...interface{}) (resultsSlice []map[string][]byte, err error)
  48. QueryInterface(sqlorArgs ...interface{}) ([]map[string]interface{}, error)
  49. QueryString(sqlorArgs ...interface{}) ([]map[string]string, error)
  50. Rows(bean interface{}) (*Rows, error)
  51. SetExpr(string, string) *Session
  52. SQL(interface{}, ...interface{}) *Session
  53. Sum(bean interface{}, colName string) (float64, error)
  54. SumInt(bean interface{}, colName string) (int64, error)
  55. Sums(bean interface{}, colNames ...string) ([]float64, error)
  56. SumsInt(bean interface{}, colNames ...string) ([]int64, error)
  57. Table(tableNameOrBean interface{}) *Session
  58. Unscoped() *Session
  59. Update(bean interface{}, condiBeans ...interface{}) (int64, error)
  60. UseBool(...string) *Session
  61. Where(interface{}, ...interface{}) *Session
  62. }
  63. // EngineInterface defines the interface which Engine, EngineGroup will implementate.
  64. type EngineInterface interface {
  65. Interface
  66. Before(func(interface{})) *Session
  67. Charset(charset string) *Session
  68. CreateTables(...interface{}) error
  69. DBMetas() ([]*core.Table, error)
  70. Dialect() core.Dialect
  71. DropTables(...interface{}) error
  72. DumpAllToFile(fp string, tp ...core.DbType) error
  73. GetColumnMapper() core.IMapper
  74. GetDefaultCacher() core.Cacher
  75. GetTableMapper() core.IMapper
  76. GetTZDatabase() *time.Location
  77. GetTZLocation() *time.Location
  78. NewSession() *Session
  79. NoAutoTime() *Session
  80. Quote(string) string
  81. SetDefaultCacher(core.Cacher)
  82. SetLogLevel(core.LogLevel)
  83. SetMapper(core.IMapper)
  84. SetTZDatabase(tz *time.Location)
  85. SetTZLocation(tz *time.Location)
  86. ShowSQL(show ...bool)
  87. Sync(...interface{}) error
  88. Sync2(...interface{}) error
  89. StoreEngine(storeEngine string) *Session
  90. TableInfo(bean interface{}) *Table
  91. UnMapType(reflect.Type)
  92. }
  93. var (
  94. _ Interface = &Session{}
  95. _ EngineInterface = &Engine{}
  96. _ EngineInterface = &EngineGroup{}
  97. )