interface.go 3.3 KB

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