Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
63c47140
Commit
63c47140
authored
Jan 09, 2019
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rollback table
parent
e0e0e372
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
table.go
vendor/github.com/33cn/chain33/common/db/table/table.go
+23
-1
No files found.
vendor/github.com/33cn/chain33/common/db/table/table.go
View file @
63c47140
...
@@ -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
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment