Client API
The syntax is as follows:
type Client interface {
// Insert a record by rowKey.
Insert(ctx context.Context, tableName string, rowKey []*table.Column, mutateColumns []*table.Column, opts ...option.ObOperationOption) (int64, error)
// Update a record by rowKey.
Update(ctx context.Context, tableName string, rowKey []*table.Column, mutateColumns []*table.Column, opts ...option.ObOperationOption) (int64, error)
// InsertOrUpdate insert or update a record by rowKey.
// insert if the primary key does not exist, update if it does.
InsertOrUpdate(ctx context.Context, tableName string, rowKey []*table.Column, mutateColumns []*table.Column, opts ...option.ObOperationOption) (int64, error)
// Replace a record by rowKey.
Replace(ctx context.Context, tableName string, rowKey []*table.Column, mutateColumns []*table.Column, opts ...option.ObOperationOption) (int64, error)
// Increment a record by rowKey.
Increment(ctx context.Context, tableName string, rowKey []*table.Column, mutateColumns []*table.Column, opts ...option.ObOperationOption) (SingleResult, error)
// Append a record by rowKey.
Append(ctx context.Context, tableName string, rowKey []*table.Column, mutateColumns []*table.Column, opts ...option.ObOperationOption) (SingleResult, error)
// Delete a record by rowKey.
Delete(ctx context.Context, tableName string, rowKey []*table.Column, opts ...option.ObOperationOption) (int64, error)
// Get a record by rowKey.
Get(ctx context.Context, tableName string, rowKey []*table.Column, getColumns []string, opts ...option.ObOperationOption) (SingleResult, error)
// Query records by rangePairs.
Query(ctx context.Context, tableName string, rangePairs []*table.RangePair, opts ...option.ObQueryOption) (QueryResultIterator, error)
// NewBatchExecutor create a batch executor.
NewBatchExecutor(tableName string, opts ...option.ObBatchOption) BatchExecutor
// NewAggExecutor create an aggregate executor.
NewAggExecutor(tableName string, rangePairs []*table.RangePair, opts ...option.ObQueryOption) AggExecutor
// Close closes the client.
// close will disconnect all connections and exit all goroutines.
Close()
}
Input parameters:
Insert: inserts a record.Update: updates a record.InsertOrUpdate: inserts a record if no primary key exists or updates a record if a primary key exists.Replace: replaces a record.Increment: increments specific integer columns in the record.mutateColumnsspecifies the delta value for increment. The value obtained after the increment can be obtained by using thefunc WithReturnAffectedEntity(returnAffectedEntity bool) ObkvOptionmethod. The delta value must be of the signed type.Append: appends a string to specific string columns in the record.mutateColumnsspecifies the delta value to be appended. The value obtained after the appending can be obtained by using thefunc WithReturnAffectedEntity(returnAffectedEntity bool) ObkvOptionmethod.Delete: deletes a record.Get: obtains a record.Query: obtains multiple records in a batch.NewBatchExecutor: creates a batch executor.NewAggExecutor: obtains an aggregate operation executor.Close: closes the client.
Columns
A column in a table has two attributes: column name and column value.
The syntax is as follows:
type Column struct {
name string
value interface{}
}
You can construct a column by using the following method:
func NewColumn(name string, value interface{}) *Column {
return &Column{name: name, value: value}
}