46 lines
651 B
Go
46 lines
651 B
Go
package sharding
|
|
|
|
import (
|
|
"context"
|
|
sqlparserX "github.com/uole/sqlparser"
|
|
)
|
|
|
|
const (
|
|
TypeDatetime = "datetime"
|
|
TypeHash = "hash"
|
|
)
|
|
|
|
const (
|
|
DateTypeYear = iota + 5
|
|
DateTypeMonth
|
|
DateTypeWeek
|
|
DateTypeDay
|
|
)
|
|
|
|
const (
|
|
sceneCreate = "create"
|
|
sceneUpdate = "update"
|
|
sceneDelete = "delete"
|
|
)
|
|
|
|
const (
|
|
stmtCountKeyword = "count"
|
|
)
|
|
|
|
type (
|
|
Rule struct {
|
|
Type string `json:"type"`
|
|
Args int `json:"args"`
|
|
}
|
|
|
|
Model interface {
|
|
ShardingRule() Rule
|
|
ShardingTable(scene string) string
|
|
ShardingTables(scope *Scope) []string
|
|
}
|
|
|
|
SelectBuilder interface {
|
|
BuildSelect(ctx context.Context, expr sqlparserX.SelectExprs) []string
|
|
}
|
|
)
|