interface.go 3.4 KB

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