-
Notifications
You must be signed in to change notification settings - Fork 0
/
otsDelete.go
34 lines (25 loc) · 959 Bytes
/
otsDelete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package otslib
import (
"fmt"
"github.com/aliyun/aliyun-tablestore-go-sdk/tablestore"
)
func DeleteComment(prodId string, commentId int64) error {
meta := new(tablestore.PrimaryKey)
meta.AddPrimaryKeyColumn("ProdId", prodId)
meta.AddPrimaryKeyColumn("CommentId", commentId)
deleteRowReq := new(tablestore.DeleteRowRequest)
deleteRowReq.DeleteRowChange = new(tablestore.DeleteRowChange)
deleteRowReq.DeleteRowChange.TableName = CommentTableName
deleteRowReq.DeleteRowChange.PrimaryKey = meta
deleteRowReq.DeleteRowChange.SetCondition(tablestore.RowExistenceExpectation_EXPECT_EXIST)
// clCondition1 := tablestore.NewSingleColumnCondition("col2", tablestore.CT_EQUAL, int64(3))
// deleteRowReq.DeleteRowChange.SetColumnCondition(clCondition1)
client := CreateClient()
_, err := client.DeleteRow(deleteRowReq)
if err != nil {
fmt.Println("getrow failed with error:", err)
} else {
fmt.Println("delete row finished")
}
return err
}