Commit 63c47140 authored by linj's avatar linj

rollback table

parent e0e0e372
...@@ -312,6 +312,16 @@ func (table *Table) getPrimaryFromData(data types.Message) (primaryKey []byte, e ...@@ -312,6 +312,16 @@ func (table *Table) getPrimaryFromData(data types.Message) (primaryKey []byte, e
return return
} }
//ListIndex list table index
func (table *Table) ListIndex(indexName string, prefix []byte, primaryKey []byte, count, direction int32) (rows []*Row, err error) {
kvdb, ok := table.kvdb.(db.KVDB)
if !ok {
return nil, errors.New("list only support KVDB interface")
}
query := &Query{table: table, kvdb: kvdb}
return query.ListIndex(indexName, prefix, primaryKey, count, direction)
}
//Replace 如果有重复的,那么替换 //Replace 如果有重复的,那么替换
func (table *Table) Replace(data types.Message) error { func (table *Table) Replace(data types.Message) error {
if err := table.checkIndex(data); err != nil { if err := table.checkIndex(data); err != nil {
...@@ -602,8 +612,15 @@ func (table *Table) getModify(row, oldrow *Row, index string) ([]byte, []byte, b ...@@ -602,8 +612,15 @@ func (table *Table) getModify(row, oldrow *Row, index string) ([]byte, []byte, b
return indexkey, oldkey, true, nil return indexkey, oldkey, true, nil
} }
//GetQuery 获取查询结构 //GetQuery 获取查询结构(允许传入 kvdb 为nil)
func (table *Table) GetQuery(kvdb db.KVDB) *Query { func (table *Table) GetQuery(kvdb db.KVDB) *Query {
if kvdb == nil {
var ok bool
kvdb, ok = table.kvdb.(db.KVDB)
if !ok {
return nil
}
}
return &Query{table: table, kvdb: kvdb} return &Query{table: table, kvdb: kvdb}
} }
...@@ -611,6 +628,11 @@ func (table *Table) getMeta() RowMeta { ...@@ -611,6 +628,11 @@ func (table *Table) getMeta() RowMeta {
return table.meta return table.meta
} }
//GetMeta 获取meta
func (table *Table) GetMeta() RowMeta {
return table.getMeta()
}
func (table *Table) getOpt() *Option { func (table *Table) getOpt() *Option {
return table.opt return table.opt
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment