Documentation ¶
Index ¶
- type Collection
- func (c *Collection) AddColumn(ctx context.Context, column string, value interface{}) error
- func (c *Collection) CreateIndex(ctx context.Context, index dal.Index) error
- func (c *Collection) Delete(ctx context.Context, filter dal.Filter) error
- func (c *Collection) DropColumn(ctx context.Context, field string) error
- func (c *Collection) DropIndex(ctx context.Context, indexName string) error
- func (c *Collection) Find(filter dal.Filter) dal.Find
- func (c *Collection) Indexes(ctx context.Context) ([]dal.Index, error)
- func (c *Collection) Insert(ctx context.Context, docs interface{}) error
- func (c *Collection) RenameColumn(ctx context.Context, oldName, newColumn string) error
- func (c *Collection) Update(ctx context.Context, filter dal.Filter, doc interface{}) error
- type Config
- type Find
- func (f *Find) All(ctx context.Context, result interface{}) error
- func (f *Find) Count(ctx context.Context) (uint64, error)
- func (f *Find) Fields(fields ...string) dal.Find
- func (f *Find) Limit(limit uint64) dal.Find
- func (f *Find) One(ctx context.Context, result interface{}) error
- func (f *Find) Sort(sort string) dal.Find
- func (f *Find) Start(start uint64) dal.Find
- type Idgen
- type Mock
- func (c *Mock) Abort(ctx context.Context) error
- func (c *Mock) Clone() dal.RDB
- func (c *Mock) Close() error
- func (c *Mock) Commit(ctx context.Context) error
- func (c *Mock) CreateTable(collName string) error
- func (c *Mock) DropTable(collName string) error
- func (c *Mock) HasTable(collName string) (bool, error)
- func (c *Mock) IsDuplicatedError(err error) bool
- func (c *Mock) IsNotFoundError(err error) bool
- func (c *Mock) Mock(retval MockResult) *Mock
- func (c *Mock) NextSequence(ctx context.Context, sequenceName string) (uint64, error)
- func (c *Mock) Ping() error
- func (c *Mock) StartTransaction(ctx context.Context) (dal.RDB, error)
- func (c *Mock) Table(collName string) dal.Table
- func (c *Mock) TxnInfo() *types.Transaction
- type MockCollection
- func (c *MockCollection) AddColumn(ctx context.Context, column string, value interface{}) error
- func (c *MockCollection) CreateIndex(ctx context.Context, index dal.Index) error
- func (c *MockCollection) Delete(ctx context.Context, filter dal.Filter) error
- func (c *MockCollection) DropColumn(ctx context.Context, field string) error
- func (c *MockCollection) DropIndex(ctx context.Context, indexName string) error
- func (c *MockCollection) Find(filter dal.Filter) dal.Find
- func (c *MockCollection) Indexes(ctx context.Context) ([]dal.Index, error)
- func (c *MockCollection) Insert(ctx context.Context, docs interface{}) error
- func (c *MockCollection) RenameColumn(ctx context.Context, oldName, newColumn string) error
- func (c *MockCollection) Update(ctx context.Context, filter dal.Filter, doc interface{}) error
- type MockFind
- func (f *MockFind) All(ctx context.Context, result interface{}) error
- func (f *MockFind) Count(ctx context.Context) (uint64, error)
- func (f *MockFind) Fields(fields ...string) dal.Find
- func (f *MockFind) Limit(limit uint64) dal.Find
- func (f *MockFind) One(ctx context.Context, result interface{}) error
- func (f *MockFind) Sort(sort string) dal.Find
- func (f *MockFind) Start(start uint64) dal.Find
- type MockResult
- type Mongo
- func (c *Mongo) Abort(ctx context.Context) error
- func (c *Mongo) Clone() dal.RDB
- func (c *Mongo) Close() error
- func (c *Mongo) Commit(ctx context.Context) error
- func (c *Mongo) CreateTable(collName string) error
- func (c *Mongo) DropTable(collName string) error
- func (c *Mongo) HasTable(collName string) (bool, error)
- func (c *Mongo) IsDuplicatedError(err error) bool
- func (c *Mongo) IsNotFoundError(err error) bool
- func (c *Mongo) NextSequence(ctx context.Context, sequenceName string) (uint64, error)
- func (c *Mongo) Ping() error
- func (c *Mongo) StartTransaction(ctx context.Context) (dal.RDB, error)
- func (c *Mongo) Table(collName string) dal.Table
- func (c *Mongo) TxnInfo() *types.Transaction
- type RPC
- func (c *RPC) Abort(ctx context.Context) error
- func (c *RPC) Clone() dal.RDB
- func (c *RPC) Close() error
- func (c *RPC) Commit(ctx context.Context) error
- func (c *RPC) CreateTable(tablename string) error
- func (c *RPC) DropTable(tablename string) error
- func (c *RPC) HasTable(tablename string) (bool, error)
- func (c *RPC) IsDuplicatedError(error) bool
- func (c *RPC) IsNotFoundError(error) bool
- func (c *RPC) NextSequence(ctx context.Context, sequenceName string) (uint64, error)
- func (c *RPC) Ping() error
- func (c *RPC) StartTransaction(ctx context.Context) (dal.RDB, error)
- func (c *RPC) Table(collection string) dal.Table
- func (c *RPC) TxnInfo() *types.Transaction
- type RPCCollection
- func (c *RPCCollection) AddColumn(ctx context.Context, column string, value interface{}) error
- func (c *RPCCollection) CreateIndex(ctx context.Context, index dal.Index) error
- func (c *RPCCollection) Delete(ctx context.Context, filter dal.Filter) error
- func (c *RPCCollection) DropColumn(ctx context.Context, field string) error
- func (c *RPCCollection) DropIndex(ctx context.Context, indexName string) error
- func (c *RPCCollection) Find(filter dal.Filter) dal.Find
- func (c *RPCCollection) Indexes(ctx context.Context) ([]dal.Index, error)
- func (c *RPCCollection) Insert(ctx context.Context, docs interface{}) error
- func (c *RPCCollection) RenameColumn(ctx context.Context, oldName, newColumn string) error
- func (c *RPCCollection) Update(ctx context.Context, filter dal.Filter, doc interface{}) error
- type RPCFind
- func (f *RPCFind) All(ctx context.Context, result interface{}) error
- func (f *RPCFind) Count(ctx context.Context) (uint64, error)
- func (f *RPCFind) Fields(fields ...string) dal.Find
- func (f *RPCFind) Limit(limit uint64) dal.Find
- func (f *RPCFind) One(ctx context.Context, result interface{}) error
- func (f *RPCFind) Sort(sort string) dal.Find
- func (f *RPCFind) Start(start uint64) dal.Find
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct { *Mongo // contains filtered or unexported fields }
Collection implement client.Collection interface
func (*Collection) AddColumn ¶
func (c *Collection) AddColumn(ctx context.Context, column string, value interface{}) error
AddColumn 添加字段
func (*Collection) CreateIndex ¶
CreateIndex 创建索引
func (*Collection) DropColumn ¶
func (c *Collection) DropColumn(ctx context.Context, field string) error
DropColumn 移除字段
func (*Collection) DropIndex ¶
func (c *Collection) DropIndex(ctx context.Context, indexName string) error
DropIndex 移除索引
func (*Collection) Find ¶
func (c *Collection) Find(filter dal.Filter) dal.Find
Find 查询多个并反序列化到 Result
func (*Collection) Insert ¶
func (c *Collection) Insert(ctx context.Context, docs interface{}) error
Insert 插入数据, docs 可以为 单个数据 或者 多个数据
func (*Collection) RenameColumn ¶
func (c *Collection) RenameColumn(ctx context.Context, oldName, newColumn string) error
RenameColumn 重命名字段
type Config ¶
type Config struct { Connect string Address string User string Password string Port string Database string Mechanism string MaxOpenConns string MaxIdleConns string }
Config config
func ParseConfigFromKV ¶
ParseConfigFromKV returns a new config
func (Config) BuildURI ¶
BuildURI return mongo uri according to https://docs.mongodb.com/manual/reference/connection-string/ format example: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
type Find ¶
type Find struct { *Collection // contains filtered or unexported fields }
Find define a find operation
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock implement client.DALRDB interface
func (*Mock) IsDuplicatedError ¶
IsDuplicatedError returns whether error is Duplicated Error
func (*Mock) IsNotFoundError ¶
IsNotFoundError returns whether error is Not Found Error
func (*Mock) Mock ¶
func (c *Mock) Mock(retval MockResult) *Mock
func (*Mock) NextSequence ¶
NextSequence 获取新序列号(非事务)
func (*Mock) StartTransaction ¶
StartTransaction 开启新事务
type MockCollection ¶
type MockCollection struct { *Mock // contains filtered or unexported fields }
MockCollection implement client.Collection interface
func (*MockCollection) AddColumn ¶
func (c *MockCollection) AddColumn(ctx context.Context, column string, value interface{}) error
AddColumn 添加字段
func (*MockCollection) CreateIndex ¶
CreateIndex 创建索引
func (*MockCollection) DropColumn ¶
func (c *MockCollection) DropColumn(ctx context.Context, field string) error
DropColumn 移除字段
func (*MockCollection) DropIndex ¶
func (c *MockCollection) DropIndex(ctx context.Context, indexName string) error
DropIndex 移除索引
func (*MockCollection) Find ¶
func (c *MockCollection) Find(filter dal.Filter) dal.Find
Find 查询多个并反序列化到 Result
func (*MockCollection) Insert ¶
func (c *MockCollection) Insert(ctx context.Context, docs interface{}) error
Insert 插入数据, docs 可以为 单个数据 或者 多个数据
func (*MockCollection) RenameColumn ¶
func (c *MockCollection) RenameColumn(ctx context.Context, oldName, newColumn string) error
RenameColumn 重命名字段
type MockFind ¶
type MockFind struct { *MockCollection `json:"-"` // contains filtered or unexported fields }
MockFind define a find operation
type MockResult ¶
type Mongo ¶
type Mongo struct {
// contains filtered or unexported fields
}
Mongo implement client.DALRDB interface
func (*Mongo) IsDuplicatedError ¶
func (*Mongo) IsNotFoundError ¶
func (*Mongo) NextSequence ¶
NextSequence 获取新序列号(非事务)
func (*Mongo) StartTransaction ¶
StartTransaction 开启新事务
type RPC ¶
type RPC struct { RequestID string // 请求ID,可选项 TxnID string // 事务ID,uuid // contains filtered or unexported fields }
RPC implement client.DALRDB interface
func NewRPCWithDiscover ¶
func NewRPCWithDiscover(getServer types.GetServerFunc) (*RPC, error)
NewRPCWithDiscover returns new RDB
func (*RPC) IsDuplicatedError ¶
func (*RPC) IsNotFoundError ¶
func (*RPC) NextSequence ¶
NextSequence 获取新序列号(非事务)
func (*RPC) StartTransaction ¶
StartTransaction 开启新事务
type RPCCollection ¶
type RPCCollection struct { RequestID string // 请求ID,可选项 Processor string // 处理进程号,结构为"IP:PORT-PID"用于识别事务session被存于那个TM多活实例 TxnID string // 事务ID,uuid // contains filtered or unexported fields }
RPCCollection implement client.Collection interface
func (*RPCCollection) AddColumn ¶
func (c *RPCCollection) AddColumn(ctx context.Context, column string, value interface{}) error
AddColumn 添加字段
func (*RPCCollection) CreateIndex ¶
CreateIndex 创建索引
func (*RPCCollection) DropColumn ¶
func (c *RPCCollection) DropColumn(ctx context.Context, field string) error
DropColumn 移除字段
func (*RPCCollection) DropIndex ¶
func (c *RPCCollection) DropIndex(ctx context.Context, indexName string) error
DropIndex 移除索引
func (*RPCCollection) Find ¶
func (c *RPCCollection) Find(filter dal.Filter) dal.Find
Find 查询多个并反序列化到 Result
func (*RPCCollection) Insert ¶
func (c *RPCCollection) Insert(ctx context.Context, docs interface{}) error
Insert 插入数据, docs 可以为 单个数据 或者 多个数据
func (*RPCCollection) RenameColumn ¶
func (c *RPCCollection) RenameColumn(ctx context.Context, oldName, newColumn string) error
RenameColumn 重命名字段
type RPCFind ¶
type RPCFind struct { *RPCCollection // contains filtered or unexported fields }
RPCFind define a find operation