Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit 6eda0cf

Browse files
committed
update readme
1 parent 762524a commit 6eda0cf

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ type Follow struct {
9292
FollowUserId int64
9393
}
9494

95+
9596
//gomodel insertUserFollowSQL = [
9697
// INSERT INTO Follow(UserId, FollowUserId)
9798
// SELECT ?, ? FROM DUAL
9899
// WHERE EXISTS(SELECT Id FROM User WHERE Id=?)
99100
//]
100101
func (f *Follow) Add() error {
101-
return f.txDo(func(tx gomodel.Tx, f *Follow) error {
102-
stmt, err := tx.PrepareById(insertUserFollowSQL)
103-
c, err := gomodel.CloseUpdate(stmt, err, gomodel.FieldVals(f, followFieldsAll, f.FollowUserId)...)
102+
return f.txDo(DB, func(tx gomodel.Tx, f *Follow) error {
103+
c, err := tx.UpdateById(insertUserFollowSQL, gomodel.FieldVals(f, followFieldsAll, f.FollowUserId)...)
104104

105105
err = dberrs.NoAffects(c, err, ErrNoUser)
106106
err = dberrs.DuplicateKeyError(err, dberrs.PRIMARY_KEY, ErrFollowed)
@@ -110,7 +110,7 @@ func (f *Follow) Add() error {
110110
}
111111

112112
func (f *Follow) Delete() error {
113-
return f.txDo(func(tx gomodel.Tx, f *Follow) error {
113+
return f.txDo(DB, func(tx gomodel.Tx, f *Follow) error {
114114
c, err := tx.Delete(f, followFieldsAll)
115115
err = dberrs.NoAffects(c, err, ErrNonFollow)
116116

@@ -127,6 +127,7 @@ func (f *Follow) updateFollowInfo(tx gomodel.Tx, err error, c int) error {
127127
}
128128
return err
129129
}
130+
130131
```
131132

132133
# LICENSE

example/userfollow/follow.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ type Follow struct {
2323
//]
2424
func (f *Follow) Add() error {
2525
return f.txDo(DB, func(tx gomodel.Tx, f *Follow) error {
26-
stmt, err := tx.PrepareById(insertUserFollowSQL)
27-
c, err := gomodel.CloseUpdate(stmt, err, gomodel.FieldVals(f, followFieldsAll, f.FollowUserId)...)
26+
c, err := tx.UpdateById(insertUserFollowSQL, gomodel.FieldVals(f, followFieldsAll, f.FollowUserId)...)
2827

2928
err = dberrs.NoAffects(c, err, ErrNoUser)
3029
err = dberrs.DuplicateKeyError(err, dberrs.PRIMARY_KEY, ErrFollowed)

0 commit comments

Comments
 (0)