2018-01-27 08:20:59 -07:00
|
|
|
// Copyright 2017 The Xorm Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package xorm
|
|
|
|
|
|
|
|
import (
|
2019-06-23 09:22:43 -06:00
|
|
|
"context"
|
2018-01-27 08:20:59 -07:00
|
|
|
"database/sql"
|
|
|
|
"reflect"
|
|
|
|
"time"
|
|
|
|
|
2020-03-22 09:12:55 -06:00
|
|
|
"xorm.io/xorm/caches"
|
2020-06-15 14:46:01 -06:00
|
|
|
"xorm.io/xorm/contexts"
|
2020-03-22 09:12:55 -06:00
|
|
|
"xorm.io/xorm/dialects"
|
|
|
|
"xorm.io/xorm/log"
|
|
|
|
"xorm.io/xorm/names"
|
|
|
|
"xorm.io/xorm/schemas"
|
2018-01-27 08:20:59 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// Interface defines the interface which Engine, EngineGroup and Session will implementate.
|
|
|
|
type Interface interface {
|
|
|
|
AllCols() *Session
|
|
|
|
Alias(alias string) *Session
|
|
|
|
Asc(colNames ...string) *Session
|
|
|
|
BufferSize(size int) *Session
|
|
|
|
Cols(columns ...string) *Session
|
|
|
|
Count(...interface{}) (int64, error)
|
|
|
|
CreateIndexes(bean interface{}) error
|
|
|
|
CreateUniques(bean interface{}) error
|
|
|
|
Decr(column string, arg ...interface{}) *Session
|
|
|
|
Desc(...string) *Session
|
|
|
|
Delete(interface{}) (int64, error)
|
|
|
|
Distinct(columns ...string) *Session
|
|
|
|
DropIndexes(bean interface{}) error
|
2019-06-23 09:22:43 -06:00
|
|
|
Exec(sqlOrArgs ...interface{}) (sql.Result, error)
|
2018-01-27 08:20:59 -07:00
|
|
|
Exist(bean ...interface{}) (bool, error)
|
|
|
|
Find(interface{}, ...interface{}) error
|
2018-07-19 20:10:17 -06:00
|
|
|
FindAndCount(interface{}, ...interface{}) (int64, error)
|
2018-01-27 08:20:59 -07:00
|
|
|
Get(interface{}) (bool, error)
|
|
|
|
GroupBy(keys string) *Session
|
|
|
|
ID(interface{}) *Session
|
|
|
|
In(string, ...interface{}) *Session
|
|
|
|
Incr(column string, arg ...interface{}) *Session
|
|
|
|
Insert(...interface{}) (int64, error)
|
|
|
|
InsertOne(interface{}) (int64, error)
|
|
|
|
IsTableEmpty(bean interface{}) (bool, error)
|
|
|
|
IsTableExist(beanOrTableName interface{}) (bool, error)
|
|
|
|
Iterate(interface{}, IterFunc) error
|
|
|
|
Limit(int, ...int) *Session
|
2018-07-19 20:10:17 -06:00
|
|
|
MustCols(columns ...string) *Session
|
2018-01-27 08:20:59 -07:00
|
|
|
NoAutoCondition(...bool) *Session
|
|
|
|
NotIn(string, ...interface{}) *Session
|
|
|
|
Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
|
|
|
|
Omit(columns ...string) *Session
|
|
|
|
OrderBy(order string) *Session
|
|
|
|
Ping() error
|
2019-06-23 09:22:43 -06:00
|
|
|
Query(sqlOrArgs ...interface{}) (resultsSlice []map[string][]byte, err error)
|
|
|
|
QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error)
|
|
|
|
QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error)
|
2018-01-27 08:20:59 -07:00
|
|
|
Rows(bean interface{}) (*Rows, error)
|
2019-09-24 07:22:39 -06:00
|
|
|
SetExpr(string, interface{}) *Session
|
2020-03-22 09:12:55 -06:00
|
|
|
Select(string) *Session
|
2018-01-27 08:20:59 -07:00
|
|
|
SQL(interface{}, ...interface{}) *Session
|
|
|
|
Sum(bean interface{}, colName string) (float64, error)
|
|
|
|
SumInt(bean interface{}, colName string) (int64, error)
|
|
|
|
Sums(bean interface{}, colNames ...string) ([]float64, error)
|
|
|
|
SumsInt(bean interface{}, colNames ...string) ([]int64, error)
|
|
|
|
Table(tableNameOrBean interface{}) *Session
|
|
|
|
Unscoped() *Session
|
|
|
|
Update(bean interface{}, condiBeans ...interface{}) (int64, error)
|
|
|
|
UseBool(...string) *Session
|
|
|
|
Where(interface{}, ...interface{}) *Session
|
|
|
|
}
|
|
|
|
|
|
|
|
// EngineInterface defines the interface which Engine, EngineGroup will implementate.
|
|
|
|
type EngineInterface interface {
|
|
|
|
Interface
|
|
|
|
|
|
|
|
Before(func(interface{})) *Session
|
|
|
|
Charset(charset string) *Session
|
2018-12-11 18:01:41 -07:00
|
|
|
ClearCache(...interface{}) error
|
2019-06-23 09:22:43 -06:00
|
|
|
Context(context.Context) *Session
|
2018-01-27 08:20:59 -07:00
|
|
|
CreateTables(...interface{}) error
|
2020-03-22 09:12:55 -06:00
|
|
|
DBMetas() ([]*schemas.Table, error)
|
2021-07-04 07:10:46 -06:00
|
|
|
DBVersion() (*schemas.Version, error)
|
2020-03-22 09:12:55 -06:00
|
|
|
Dialect() dialects.Dialect
|
|
|
|
DriverName() string
|
2018-01-27 08:20:59 -07:00
|
|
|
DropTables(...interface{}) error
|
2020-03-22 09:12:55 -06:00
|
|
|
DumpAllToFile(fp string, tp ...schemas.DBType) error
|
|
|
|
GetCacher(string) caches.Cacher
|
|
|
|
GetColumnMapper() names.Mapper
|
|
|
|
GetDefaultCacher() caches.Cacher
|
|
|
|
GetTableMapper() names.Mapper
|
2018-01-27 08:20:59 -07:00
|
|
|
GetTZDatabase() *time.Location
|
|
|
|
GetTZLocation() *time.Location
|
2020-03-22 09:12:55 -06:00
|
|
|
ImportFile(fp string) ([]sql.Result, error)
|
|
|
|
MapCacher(interface{}, caches.Cacher) error
|
2018-01-27 08:20:59 -07:00
|
|
|
NewSession() *Session
|
|
|
|
NoAutoTime() *Session
|
|
|
|
Quote(string) string
|
2020-03-22 09:12:55 -06:00
|
|
|
SetCacher(string, caches.Cacher)
|
2018-12-11 18:01:41 -07:00
|
|
|
SetConnMaxLifetime(time.Duration)
|
2020-03-22 09:12:55 -06:00
|
|
|
SetColumnMapper(names.Mapper)
|
2021-05-14 13:17:06 -06:00
|
|
|
SetTagIdentifier(string)
|
2020-03-22 09:12:55 -06:00
|
|
|
SetDefaultCacher(caches.Cacher)
|
|
|
|
SetLogger(logger interface{})
|
|
|
|
SetLogLevel(log.LogLevel)
|
|
|
|
SetMapper(names.Mapper)
|
2018-12-11 18:01:41 -07:00
|
|
|
SetMaxOpenConns(int)
|
|
|
|
SetMaxIdleConns(int)
|
2020-03-22 09:12:55 -06:00
|
|
|
SetQuotePolicy(dialects.QuotePolicy)
|
2018-07-19 20:10:17 -06:00
|
|
|
SetSchema(string)
|
2020-03-22 09:12:55 -06:00
|
|
|
SetTableMapper(names.Mapper)
|
2018-01-27 08:20:59 -07:00
|
|
|
SetTZDatabase(tz *time.Location)
|
|
|
|
SetTZLocation(tz *time.Location)
|
2020-06-15 14:46:01 -06:00
|
|
|
AddHook(hook contexts.Hook)
|
2018-01-27 08:20:59 -07:00
|
|
|
ShowSQL(show ...bool)
|
|
|
|
Sync(...interface{}) error
|
|
|
|
Sync2(...interface{}) error
|
|
|
|
StoreEngine(storeEngine string) *Session
|
2020-03-22 09:12:55 -06:00
|
|
|
TableInfo(bean interface{}) (*schemas.Table, error)
|
2018-07-19 20:10:17 -06:00
|
|
|
TableName(interface{}, ...bool) string
|
2018-01-27 08:20:59 -07:00
|
|
|
UnMapType(reflect.Type)
|
2020-07-21 06:28:27 -06:00
|
|
|
EnableSessionID(bool)
|
2018-01-27 08:20:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ Interface = &Session{}
|
|
|
|
_ EngineInterface = &Engine{}
|
|
|
|
_ EngineInterface = &EngineGroup{}
|
|
|
|
)
|